在 GWT 中使用嵌入式 Neo4j 时出现 AccessControlException
Posted
技术标签:
【中文标题】在 GWT 中使用嵌入式 Neo4j 时出现 AccessControlException【英文标题】:AccessControlException when using Embedded Neo4j in GWT 【发布时间】:2015-02-19 03:46:23 【问题描述】:有人有在 GWT 中使用嵌入式 Neo4j 的经验吗?尝试创建嵌入式数据库时出现 AccessControlException。
这是我用来在 ServiceImpl 文件中创建数据库的行:
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("/var/uwcompanygraph");
这是堆栈跟踪:
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.coreywu.uwcompanygraph.client.CompanyGraph com.coreywu.uwcompanygraph.client.QueryGraphService.getGraph()' threw an unexpected exception: java.security.AccessControlException: access denied ("java.io.FilePermission" "\var\uwcompanygraph" "read")
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "\var\uwcompanygraph" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.io.File.exists(File.java:808)
at org.neo4j.kernel.DefaultFileSystemAbstraction.mkdirs(DefaultFileSystemAbstraction.java:111)
at org.neo4j.kernel.impl.util.StringLogger$ActualStringLogger.<init>(StringLogger.java:582)
at org.neo4j.kernel.impl.util.StringLogger$ActualStringLogger.<init>(StringLogger.java:560)
at org.neo4j.kernel.impl.util.StringLogger.loggerDirectory(StringLogger.java:109)
at org.neo4j.kernel.logging.ClassicLoggingService.<init>(ClassicLoggingService.java:41)
at org.neo4j.kernel.logging.ClassicLoggingService.<init>(ClassicLoggingService.java:36)
at org.neo4j.kernel.logging.LogbackWeakDependency$1.apply(LogbackWeakDependency.java:41)
at org.neo4j.kernel.logging.LogbackWeakDependency$1.apply(LogbackWeakDependency.java:37)
at org.neo4j.kernel.logging.LogbackWeakDependency.tryLoadLogbackService(LogbackWeakDependency.java:98)
at org.neo4j.kernel.logging.LogbackWeakDependency.tryLoadLogbackService(LogbackWeakDependency.java:103)
at org.neo4j.kernel.logging.DefaultLogging.createDefaultLogging(DefaultLogging.java:42)
at org.neo4j.kernel.InternalAbstractGraphDatabase.createLogging(InternalAbstractGraphDatabase.java:979)
at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:442)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:336)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:91)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:181)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:71)
at com.coreywu.uwcompanygraph.server.QueryGraphServiceImpl.getGraph(QueryGraphServiceImpl.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more
【问题讨论】:
【参考方案1】:您的 JVM 已启用 Java SecurityManager。禁用它或为将 I/O 权限授予/var/uwcompanygraph
的安全管理器设置适当的策略。
根据GWT的FAQ列表,Google App Engine的Eclipse插件中有一个设置可能会被错误激活,见http://www.gwtproject.org/doc/latest/FAQ_Troubleshooting.html#AccessControlException_access_denied。
【讨论】:
以上是关于在 GWT 中使用嵌入式 Neo4j 时出现 AccessControlException的主要内容,如果未能解决你的问题,请参考以下文章
尝试在枚举中添加 IsSerializable 时出现 gwt 错误