应用程序引擎上的slf4j AccessControlException

时间:2015-04-05 22:14:12

标签: java google-app-engine slf4j

我要做的就是使用luceneappengine's GaeDirectory。显然它需要有slf4j。所以我将jar slf4j-api-1.7.12.jar添加到我的项目中。现在我收到以下错误跟踪。因此,luceneappengine是为GAE明确创建的。那么为什么在Java本身带有记录器时,它需要一个不易支持的记录器?我在这里缺少什么?

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method
java.lang.ExceptionInInitializerError
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:149)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:120)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:331)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:283)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:304)
    at com.googlecode.luceneappengine.GaeDirectory.<clinit>(GaeDirectory.java:56)
    …
    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:45)
    at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
    at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
    at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
    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.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    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 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.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createSecurityManager")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)
    at java.security.AccessController.checkPermission(AccessController.java:572)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.<init>(SecurityManager.java:299)
    at org.slf4j.helpers.Util$ClassContextSecurityManager.<init>(Util.java:43)
    at org.slf4j.helpers.Util$ClassContextSecurityManager.<init>(Util.java:43)
    at org.slf4j.helpers.Util.<clinit>(Util.java:49)
    ... 42 more

3 个答案:

答案 0 :(得分:2)

您遇到的问题由以下异常识别(与上面给出的根本原因相同)

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createSecurityManager")
  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)
  at java.security.AccessController.checkPermission(AccessController.java:572)
  at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
  at java.lang.SecurityManager.<init>(SecurityManager.java:299)
  at org.slf4j.helpers.Util$ClassContextSecurityManager.<init>(Util.java:43)
  at org.slf4j.helpers.Util$ClassContextSecurityManager.<init>(Util.java:43)
  at org.slf4j.helpers.Util.<clinit>(Util.java:49)

特定于slf4j-api版本 1.7.9至1.7.12 。它已在昨天发布的版本 1.7.13 中修复,以解决同样的问题。

答案 1 :(得分:0)

SLF4J应该有效,你确定你使用的是LAE依赖项中定义的相同版本吗?

尝试此处说明的设置:http://blog.xam.de/2010/03/logging-in-google-appengine-for-java.html

答案 2 :(得分:0)

我遇到了同样的问题,结果是因为我有2个slf4j实现。我明确地使用了slf4j-jdk14,这似乎是GAE推荐的实现,我的一个库(Apache Jena)引入了slf4j-log4j12。

我的调试输出中的某个地方(以及上面列出的错误)是org.slf4j.LoggerFactory.reportMultipleBindingAmbiguity(以及AccessControlException)。

我不确定为什么Jena会包含slf4j-log4j12 - 我的其他库只依赖于slf4j-api并将实现选择留给用户。无论如何,我从Jena中排除了slf4j-log4j12,在我看来是这样的:

compile ('org.apache.jena:apache-jena-libs:2.11.1')   {
    exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}

事情又开始了。