使用Jersey 2.1x的Google Appengine在开发服务器中运行良好,但在Appengine服务器中运行不正常

时间:2015-07-11 06:54:15

标签: java google-app-engine guice jersey-2.0 hk2

我一直在使用带有Google Appengine v1.9.22的Jersey v2.19,它在本地devserver中工作正常,没有任何问题,但是当我尝试将应用程序部署到appengine时。我得到了多个例外

使用的框架:

AppEngine Java 1.9.22

泽西岛2.19

Objectify 5.1.5

Guice 3.x

Gradle

以下是我在日志中收到的异常:

org.glassfish.jersey.internal.Errors logErrors:检测到以下警告:警告:检测到未知的HK2故障:

MultiException堆栈1 of 4

java.security.AccessControlException:拒绝访问(" java.lang.RuntimePermission"" getClassLoader")     在com.google.appengine.runtime.Request.process-84bc59f0ba240851(Request.java)     at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)     at java.security.AccessController.checkPermission(AccessController.java:572)     在java.lang.SecurityManager.checkPermission(SecurityManager.java:549)     at java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:1606)     在java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1525)     在org.jvnet.hk2.internal.ProxyUtilities $ 1.run(ProxyUtilities.java:95)     在org.jvnet.hk2.internal.ProxyUtilities $ 1.run(ProxyUtilities.java:90)     在java.security.AccessController.doPrivileged(AccessController.java:34)     在org.jvnet.hk2.internal.ProxyUtilities.secureCreate(ProxyUtilities.java:90)     在org.jvnet.hk2.internal.ProxyUtilities.generateProxy(ProxyUtilities.java:206)     在org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2038)     在org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)     at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)     在org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:126)     在org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:214)     在org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:237)     在org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:360)     at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:470)     在org.jvnet.hk2.internal.SingletonContext $ 1.compute(SingletonContext.java:82)     在org.jvnet.hk2.internal.SingletonContext $ 1.compute(SingletonContext.java:70)     在org.glassfish.hk2.utilities.cache.Cache $ OriginThreadAwareFuture $ 1.call(Cache.java:97)     在java.util.concurrent.FutureTask.run(FutureTask.java:260)     在org.glassfish.hk2.utilities.cache.Cache $ OriginThreadAwareFuture.run(Cache.java:154)     在org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)     at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:121)     在org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2065)     在org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)     at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)     在org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:247)     在org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:758)     在org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:536)     在org.glassfish.jersey.server.ApplicationHandler.access $ 500(ApplicationHandler.java:183)     在org.glassfish.jersey.server.ApplicationHandler $ 3.call(ApplicationHandler.java:349)     在org.glassfish.jersey.server.ApplicationHandler $ 3.call(ApplicationHandler.java:346)     在org.glassfish.jersey.internal.Errors.process(Errors.java:315)     在org.glassfish.jersey.internal.Errors.process(Errors.java:297)     在org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)     在org.glassfish.jersey.server.ApplicationHandler。(ApplicationHandler.java:346)     在org.glassfish.jersey.servlet.WebComponent。(WebComponent.java:339)     在org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)     在org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:393)     在org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)     在org.mortbay.jetty.servlet.Context.startContext(Context.java:140)     at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)     在org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)     在org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)     在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)     在com.google.tracing.TraceContext $ TraceContextRunnable.runInContext(TraceContext.java:437)     在com.google.tracing.TraceContext $ TraceContextRunnable $ 1.run(TraceContext.java:444)     在com.google.tracing.CurrentContext.runInContext(CurrentContext.java:230)     在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)     在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)     在com.google.tracing.TraceContext $ TraceContextRunnable.run(TraceContext.java:441)     在java.lang.Thread.run(Thread.java:745)

MultiException stack 2 of 4

java.lang.IllegalArgumentException:尝试在范围org.glassfish.jersey.process.internal.RequestScoped中为javax.servlet.http.HttpServletRequest创建代理时创建代理时出错     在org.jvnet.hk2.internal.ProxyUtilities.generateProxy(ProxyUtilities.java:212)     在org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2038)     在org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)     at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)     在org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:126)

...修剪

MultiException stack 3 of 4

java.lang.IllegalArgumentException:尝试解决com.app.webapp.filters.WebApiAuthFilter的依赖关系时发现错误

MultiException stack 4 of 4

java.lang.IllegalStateException:无法执行操作:解析com.app.webapp.filters.WebApiAuthFilter

我已经搜索了可能的修复,但无法找到与我的问题相关的任何内容,我使用JDO或JPA,因此asm jar不兼容不是原因。

有关如何解决此问题的任何想法?

更新:

我试图弄清楚这个异常的原因,我有一个过滤器,其中我注入了HttpServletRequest,因为这样抛出了异常,但不确定原因。

@Provider
@WebApiAuth
public class AuthFilter implements ContainerRequestFilter {

 // problem is because of injecting this 
  @Context
  protected HttpServletRequest servletRequest;
}

1 个答案:

答案 0 :(得分:2)

这对您来说可能为时已晚,但为了帮助他人 - 我在尝试访问request.getRemoteAddr()时遇到了同样的问题。注入HttpServletRequest会在运行时抛出此错误,并且没有任何环境变量,请求属性或标头包含远程地址。

https://stackoverflow.com/a/23590606/3037408

提供一个可以添加' remote_addr'的工作解决方案。标题进入泽西/ jaxrs标题。如果您需要从HttpServletRequest访问remote_addr以外的其他内容,您可以将相关数据插入到标题或其他属性中以供以后访问。