如何在Glassfish中允许该权限

时间:2012-03-19 17:06:02

标签: java security glassfish neo4j policy

在我的Glassfish服务器上,我最近启用了安全管理器。一旦我这样做,我使用的neo4j-JCA connector已停止工作,抱怨异常:

Caused by: java.security.AccessControlException: access denied (java.lang.management.ManagementPermission monitor)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at sun.management.ManagementFactory.checkAccess(ManagementFactory.java:223)
    at sun.management.ManagementFactory.checkMonitorAccess(ManagementFactory.java:228)
    at sun.management.RuntimeImpl.getBootClassPath(RuntimeImpl.java:89)
    at org.neo4j.kernel.ConfigurationLogging.logConfig(ConfigurationLogging.java:91)
    at org.neo4j.kernel.GraphDbInstance.start(GraphDbInstance.java:166)
    at org.neo4j.kernel.EmbeddedGraphDbImpl.<init>(EmbeddedGraphDbImpl.java:190)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:80)
    at com.netoprise.neo4j.Neo4jManagedConnectionFactory.createDatabase(Neo4jManagedConnectionFactory.java:278)
    at com.netoprise.neo4j.Neo4jManagedConnectionFactory.createManagedConnection(Neo4jManagedConnectionFactory.java:154)
    at com.sun.enterprise.resource.allocator.ConnectorAllocator.createResource(ConnectorAllocator.java:160)
    at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
    ... 74 more

我知道我必须在server.policy中写一些东西,但是什么?我试过了

//Neo4J management permission for logging
grant  codeBase "file:${com.sun.aas.installRoot}/neo4j-connector-0.3-SNAPSHOT/-"{
      permission java.lang.management.ManagementPermission "monitor";
};

绝对没有效果。那么我应该使用什么语法? (注意neo4j-connector-0.3-SNAPSHOT是Neo4J的JCA连接器的名称

1 个答案:

答案 0 :(得分:0)

尝试将权限放在JCA描述符文件ra.xml中。这是example

        <security-permission>
            <security-permission-spec> permission java.io.FilePermission
                "/tmp/db/fs_store/*", "read,write"; 
            </security-permission-spec>
        </security-permission>