Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 4.0_b89_RC5
    • Fix Version/s: None
    • Component/s: jax-rs
    • Labels:
      None
    • Environment:

      Glassfish 4.0 with latest updates and running on JDK 1.7.0_25.

      Description

      I have a simple JAX-RS application:

      @ApplicationPath("/")
      public final class MavenUpdateServerApplication extends Application {
      
          private @Nullable URI configuration;
      
          public MavenUpdateServerApplication(final URI configuration) {
              this.configuration = Objects.requireNonNull(configuration);
          }
      
          public MavenUpdateServerApplication() { }
      
          @Context
          public void setContext(ServletContext context)
          throws URISyntaxException {
              this.configuration = new URI(SystemProperties.resolve(
                      context.getInitParameter("configuration")));
          }
      
          ...
      }
      

      This class is bundled within a regular JAR.

      Then I have a WAR which bundles this JAR and its dependencies in WEB-INF/lib. The WAR has a WEB-INF/web.xml which looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
               version="3.0">
          <context-param>
              <param-name>configuration</param-name>
              <param-value>net/java/trueupdate/artifact/impl/maven/main-repositories.xml</param-value>
          </context-param>
      </web-app>
      

      Now at runtime, the setContext() method does get called, but the parameter is always null, so that I get:

      SEVERE:   WebModule[/trueupdate-server-appl-javaee]StandardWrapper.Throwable
      MultiException stack 1 of 1
      java.lang.NullPointerException
      	at net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication.setContext(MavenUpdateServerApplication.java:55)
      	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 org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1010)
      	at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:795)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:790)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:863)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:855)
      	at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:293)
      	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:272)
      	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
      	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.allocate(StandardWrapper.java:1225)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      	at java.lang.Thread.run(Thread.java:724)
      
      WARNING:   StandardWrapperValve[net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication]: Allocate exception for servlet net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication
      java.lang.NullPointerException
      	at net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication.setContext(MavenUpdateServerApplication.java:55)
      	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 org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1010)
      	at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:795)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:790)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:863)
      	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:855)
      	at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:293)
      	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:272)
      	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
      	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.allocate(StandardWrapper.java:1225)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      	at java.lang.Thread.run(Thread.java:724)
      

      The same code runs fine on Apache Tomcat 7.0.42 with the Jersey Servlet 1.17.1.

        Activity

        Hide
        Christian Schlichtherle added a comment -

        I also get a NullPointerException when trying to inject a ContextResolver into a root resource class like this:

            @Context
            public void setContextResolver(
                    ContextResolver<ArtifactResolver> contextResolver) {
                this.artifactResolver = contextResolver.getContext(null);
            }
        

        Seems that I cannot have injected any @Context parameters.

        Show
        Christian Schlichtherle added a comment - I also get a NullPointerException when trying to inject a ContextResolver into a root resource class like this: @Context public void setContextResolver( ContextResolver<ArtifactResolver> contextResolver) { this .artifactResolver = contextResolver.getContext( null ); } Seems that I cannot have injected any @Context parameters.
        Hide
        RobertoGB added a comment -

        I think that could be jersey issue.

        Show
        RobertoGB added a comment - I think that could be jersey issue.
        Hide
        cowwoc added a comment -

        It is. See JERSEY-2184

        Show
        cowwoc added a comment - It is. See JERSEY-2184

          People

          • Assignee:
            Unassigned
            Reporter:
            Christian Schlichtherle
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: