glassfish
  1. glassfish
  2. GLASSFISH-20885

Jersey 2.4: deployment exception when using @Context HttpServletRequest in ContainerRequestFilter

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 4.1
    • Fix Version/s: None
    • Component/s: jax-rs
    • Labels:
      None

      Description

      Downloaded and installed Glassfish 4.0.1 latest nightly version with bundled Jersey 2.4 from http://dlc.sun.com.edgesuite.net/glassfish/4.0.1/nightly/glassfish-4.0.1-b04-11_04_2013.zip

      Using ContainerRequestFilter with injected context HttpServletRequest:

      @Provider
      @Priority(Priorities.AUTHENTICATION)
      public class AuthRequestFilter implements ContainerRequestFilter {
          @Context
          HttpServletRequest webRequest;
      
          @Override
          public void filter(ContainerRequestContext requestContext) throws IOException {
              HttpSession session = webRequest.getSession();
              String user = (String)session.getAttribute("USER_ID");
          }
      }
      

      And get exception during deployment:

          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
          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:286)
          at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
          at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
          at javax.servlet.GenericServlet.init(GenericServlet.java:244)
          at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
      java.lang.IllegalArgumentException: While attempting to create a Proxy for javax.servlet.http.HttpServletRequest in proxiable scope org.glassfish.jersey.process.internal.RequestScoped an error occured while creating the proxy
          at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2309)
          at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
          at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
          at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:104)
          at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:803)
          at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:832)
          at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.getInstance(CdiComponentProvider.java:203)
          at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.provide(CdiComponentProvider.java:149)
          at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96)
          at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
          at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
          at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2350)
          at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
          at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
          at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:235)
          at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:617)
          at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:410)
          at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
          at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:287)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
          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:286)
          at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
          at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
          at javax.servlet.GenericServlet.init(GenericServlet.java:244)
          at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
          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:286)
          at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
          at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
          at javax.servlet.GenericServlet.init(GenericServlet.java:244)
          at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
          Startup of context  failed due to previous errors]]
      
      [glassfish 4.0] [SEVERE] [AS-WEB-CORE-00108] [javax.enterprise.web.core] [tid: _ThreadID=50 _ThreadName=admin-listener(4)] [timeMillis: 1383814486801] [levelValue: 1000] [[
        ContainerBase.addChild: start:
      org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: interface org.glassfish.hk2.api.ProxyCtl is not visible from class loader
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5954)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
          at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
          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:286)
          at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
          at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
          at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
          at javax.servlet.GenericServlet.init(GenericServlet.java:244)
          at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
          ... 50 more
          ]]
      

      This exception disappears when I remove HttpServletRequest injection.

        Issue Links

          Activity

          Hide
          dobromyslov added a comment - - edited
          Show
          dobromyslov added a comment - - edited Question on StackOverflow: http://stackoverflow.com/questions/19832012/jersey-2-4-on-glassfish-4-0-1-how-to-inject-context-httpservletrequest-into-con Jersey 2.4 supports HttpServletRequest injection: https://java.net/jira/browse/JERSEY-1960
          Hide
          cornelius.lilge added a comment -

          Unfortunately, I can reproduce this D:
          I would really like to use this.

          Show
          cornelius.lilge added a comment - Unfortunately, I can reproduce this D: I would really like to use this.
          Hide
          Scott Ellis added a comment -

          This is a show stopper for me, as I'm trying to inject the HttpServletRequest into a filter and have to work around this by not using a filter at all.

          The issue is fixed with the nightly build from 12/25 and possibly onward.

          I'm in the position of taking a chance and using that nightly version in production or backing off completely. I don't know how the process works, but I'd like to know when 4.0.1 (or 4.1) will be available as either beta or release.

          Show
          Scott Ellis added a comment - This is a show stopper for me, as I'm trying to inject the HttpServletRequest into a filter and have to work around this by not using a filter at all. The issue is fixed with the nightly build from 12/25 and possibly onward. I'm in the position of taking a chance and using that nightly version in production or backing off completely. I don't know how the process works, but I'd like to know when 4.0.1 (or 4.1) will be available as either beta or release.
          Hide
          dobromyslov added a comment -
          Show
          dobromyslov added a comment - Tested with nightly build from 2014-02-13: http://dlc.sun.com.edgesuite.net/glassfish/4.0.1/nightly/glassfish-4.0.1-b04-02_13_2014-ml.zip Works well.

            People

            • Assignee:
              Unassigned
              Reporter:
              dobromyslov
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: