2
votes

I have been using Jersey v2.19 with Google Appengine v1.9.22 and it works fine in local devserver without any issue, but when i tried to deploy the application to appengine. I get multiple exceptions

Frameworks Used :

AppEngine Java 1.9.22

Jersey 2.19

Objectify 5.1.5

Guice 3.x

Gradle

Following is the exception i get in the log:

org.glassfish.jersey.internal.Errors logErrors: The following warnings have been detected: WARNING: Unknown HK2 failure detected:

MultiException stack 1 of 4

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader") at 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) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:1606) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1525) at org.jvnet.hk2.internal.ProxyUtilities$1.run(ProxyUtilities.java:95) at org.jvnet.hk2.internal.ProxyUtilities$1.run(ProxyUtilities.java:90) at java.security.AccessController.doPrivileged(AccessController.java:34) at org.jvnet.hk2.internal.ProxyUtilities.secureCreate(ProxyUtilities.java:90) at org.jvnet.hk2.internal.ProxyUtilities.generateProxy(ProxyUtilities.java:206) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2038) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:126) at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:214) at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:237) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:360) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:470) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:82) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:70) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask.run(FutureTask.java:260) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:121) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2065) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:247) at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:758) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:536) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:183) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:349) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:346) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:346) at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:339) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:393) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 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:230) 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)

MultiException stack 2 of 4

java.lang.IllegalArgumentException: While attempting to create a Proxy for javax.servlet.http.HttpServletRequest in scope org.glassfish.jersey.process.internal.RequestScoped an error occured while creating the proxy at org.jvnet.hk2.internal.ProxyUtilities.generateProxy(ProxyUtilities.java:212) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2038) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:126)

... trimmed

MultiException stack 3 of 4

java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.app.webapp.filters.WebApiAuthFilter errors were found

MultiException stack 4 of 4

java.lang.IllegalStateException: Unable to perform operation: resolve on com.app.webapp.filters.WebApiAuthFilter

i have searched for possible fix, but couldn't able to find anything relates to my problem, i dint use JDO or JPA so the asm jar incompatibility is not the cause.

Any idea on how to resolve this issue ?

Update :

I tried to figure out the cause for this exception, I have an Filter in which i have injected HttpServletRequest , exception is thrown because of that, not sure why though.

@Provider
@WebApiAuth
public class AuthFilter implements ContainerRequestFilter {

 // problem is because of injecting this 
  @Context
  protected HttpServletRequest servletRequest;
}
1
seems that HK2 is incompatible with AppengineIgor Artamonov
ya kind of , just now tried to upload an another gae module with jersey without any guice or hk2 dependencies and it works fine, any idea how to resolve this?Ramesh Lingappa
That looks like a J2SE security exception. Which likely means you have not granted sufficient privileges to the hk2/jersey code base. You should make sure that Jersey/HK2 has been granted AllPermission. You can see that it is hk2 doing a "doPrivileged" but it does not appear to have the permissions it needs to create the proxy.jwells131313

1 Answers

2
votes

This is probably too late for you, but in the interest of helping others -- I was facing the same problem trying to get access to request.getRemoteAddr(). Injecting HttpServletRequest threw this error at runtime, and none of the environment variables, request properties, or headers contained the remote address.

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

Provides a working solution that adds a 'remote_addr' header into the jersey/jaxrs headers. If you needed to access something other than the remote_addr from the HttpServletRequest, you could probably insert the relevant data into the headers or some other property for later access as well.