我有一个应用程序,使用RMI和工作时,我有安全策略设置为
//
// Allow everything for now
//
permission java.security.AllPermission;
但是,当我试图用下面的策略锁定它时,我得到了这个异常-这让我认为类路径的某些内容是关闭的,我需要在策略中添加一些关于类路径的内容,但我不知道是什么。
也-任何想法为什么我必须设置套接字权限所有不同的方式(环回,名称,基础ip)?
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil
at org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:78)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:61)
grant codeBase "file:/C:/apps/abc/xyz/*" {
//
// Allow everything for now
//permission java.security.AllPermission;
permission java.net.SocketPermission "127.0.0.1:*", "accept,connect,resolve";
permission java.net.SocketPermission "localhost:6990", "listen,accept,connect,resolve";
permission java.net.SocketPermission "localhost:6993", "listen,accept,connect,resolve";
permission java.net.SocketPermission "XPS7590.abc.local", "resolve";
permission java.net.SocketPermission "192.168.1.125:6993", "listen,accept,connect,resolve";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "LicenseFilename", "read";
permission java.util.PropertyPermission "HostId", "read";
permission java.io.FilePermission ".", "read";
permission java.io.FilePermission "C:/Apps/abc/xyz/-", "read";
permission java.lang.RuntimePermission "setFactory";
permission java.lang.RuntimePermission "createClassLoader";
//permission java.lang.RuntimePermission "setContextClassLoader";
};
解决这个问题的方法是在我的策略文件中添加以下行:
permission java.lang.RuntimePermission "getClassLoader";