AccessControlException尝试删除文件时 [英] AccessControlException when attempting to delete a file

查看:185
本文介绍了AccessControlException尝试删除文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用log4j进行日志记录的java web服务应用程序。 log4j尝试删除滚动日志文件时抛出一个异常

 异常:java.security.AccessControlException:访问被拒绝
(java.io.FilePermission / var / opt / SUNWappserver / domains / domain1 /
applications / j2ee-modules / ourwebservice / WEB-INF / logs / IMWrapper.log.10 delete)

当我们在目录中执行 ls 时,服务帐户可以访问读取和写入文件和目录。

从一些最初的谷歌搜索似乎我们可能不得不改变 security.policy 文件以允许服务删除文件。任何建议吗?

解决方案

作为一个quickfix,您可以使用包含以下内容的策略文件启动应用程序:

  grant {
permission java.security.AllPermission;
};

使用命令行选项:

-Djava.security.policy = file:< your_policy_file>



请参阅此链接了解更多信息如何配置您的政策文件以获得所需的访问权限。


$ b $编辑:我很抱歉,但我不知道如何配置您的Web应用程序如何使用该策略文件,但至少该链接应该暗示你获得所需的权利...


We have a java web service application that uses log4j to do logging. An exception gets thrown when log4j tries to delete its rolling log files

Exception:java.security.AccessControlException: access denied
(java.io.FilePermission /var/opt/SUNWappserver/domains/domain1/
applications/j2ee-modules/ourwebservice/WEB-INF/logs/IMWrapper.log.10 delete)

When we do an ls in the directory the service account does have access to read and write to the files and the directory.

From some initial Googling it seems we may have to change the security.policy file to allow the service to delete files. Any suggestions?

解决方案

As a quickfix you can start the application using a policy file with the following content:

grant {
    permission java.security.AllPermission;
};

using the command line option:

-Djava.security.policy=file:<your_policy_file>

See this link for more info how to configure your policy file to get the required access rights.

EDIT: I'm sorry, but I don't know how to configure your web application how to use that policy file, but at least the link should hint you towards getting the required rights...

这篇关于AccessControlException尝试删除文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆