描述
The following error occurs from an application client or in the server.log:
java.security.AccessControlException: access denied
(java.util.PropertyPermission name write…
There is a permissions issue in the policy files. Either the client.policy for the application client or the server.policy for server side components does not have permission to set the property.
解决
Add the permission in client.policy (for the application client), or in server.policy (for EJB/web modules) for the application that needs to set the property. By default, applications only have “read” permission for properties.
For example, to grant read/write permission for all the files in the codebase directory, add or append the following to client.policy or server.policy:
grant codeBase "file:/.../build/sparc_SunOS/sec/-" {
permission java.util.PropertyPermission "*", "read,write";
};
参考:https://docs.oracle.com/cd/E19830-01/819-4726/fxxzk/index.html
到运行的$JAVA_HOME中查找xx.policy文件,再在里边内容做修改即可
find . -type f -name "*.policy"
注意:本地运行没这样问题而生产有,则可考虑生产对应的文件被修改从而影响了本来程序(可考虑还原配置来确定是什么配置影响了)
Java安全异常解决
本文解决了一个常见的Java安全异常问题:AccessControlException。该错误通常发生在尝试写入属性但权限不足时。通过修改客户端或服务器的策略文件,可以授予应用程序读写属性的权限。
1万+

被折叠的 条评论
为什么被折叠?



