jersey
  1. jersey
  2. JERSEY-660

NPE in com.sun.jersey.core.impl.provider.header.WriterUtil.appendQuotedIfWhiteSpaceOrQuote(WriterUtil.java:59)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.5
    • Fix Version/s: 1.18
    • Component/s: core
    • Labels:
      None
    • Environment:

      Netbeans 6.9.1
      Glassfish 3.0.1

      Description

      This issue is 100% reproducible on my end, but I don't have a minimal testcase for it. I can probably produce one if you really need it.

      Repro steps:

      1. Deploy webapp
      2. Jersey launches okay
      3. Modify webapp, compile and redeploy it
      4. Jersey throws the following exception:

      com.sun.jersey.api.container.ContainerException: Unable to create resource
      at com.sun.jersey.server.impl.resource.SingletonFactory$Singleton.init(SingletonFactory.java:139)
      at com.sun.jersey.server.impl.application.WebApplicationImpl$9.f(WebApplicationImpl.java:540)
      at com.sun.jersey.server.impl.application.WebApplicationImpl$9.f(WebApplicationImpl.java:538)
      at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.getResourceComponentProvider(WebApplicationImpl.java:538)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.initiateResource(WebApplicationImpl.java:613)
      at com.sun.jersey.server.impl.application.RootResourceUriRules.initWadlResource(RootResourceUriRules.java:215)
      at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:193)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1184)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.access$600(WebApplicationImpl.java:159)
      at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:700)
      at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:697)
      at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:697)
      at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.initiate(GuiceContainer.java:118)
      at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
      at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:606)
      at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:213)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
      at javax.servlet.GenericServlet.init(GenericServlet.java:242)
      at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:83)
      at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:84)
      at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:106)
      at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:168)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:200)
      at com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:182)
      at com.sun.jersey.server.impl.resource.SingletonFactory$Singleton.init(SingletonFactory.java:137)
      ... 50 more
      Caused by: java.lang.NullPointerException
      at com.sun.jersey.core.impl.provider.header.WriterUtil.appendQuotedIfWhiteSpaceOrQuote(WriterUtil.java:59)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:68)
      at com.sun.jersey.core.impl.provider.header.MediaTypeProvider.toString(MediaTypeProvider.java:53)
      at javax.ws.rs.core.MediaType.toString(MediaType.java:265)
      at com.sun.jersey.server.wadl.WadlGeneratorImpl.createResponseRepresentation(WadlGeneratorImpl.java:206)
      at com.sun.jersey.server.wadl.WadlGeneratorImpl.createResponse(WadlGeneratorImpl.java:193)
      at com.sun.jersey.server.wadl.WadlBuilder.generateResponse(WadlBuilder.java:397)
      at com.sun.jersey.server.wadl.WadlBuilder.generateMethod(WadlBuilder.java:166)
      at com.sun.jersey.server.wadl.WadlBuilder.generateResource(WadlBuilder.java:308)
      at com.sun.jersey.server.wadl.WadlBuilder.generateResource(WadlBuilder.java:271)
      at com.sun.jersey.server.wadl.WadlBuilder.generate(WadlBuilder.java:107)
      at com.sun.jersey.server.impl.wadl.WadlApplicationContextImpl.getApplication(WadlApplicationContextImpl.java:76)
      at com.sun.jersey.server.impl.wadl.WadlResource.<init>(WadlResource.java:76)
      ... 57 more

      Workaround: Restart Glassfish every time the webapp is modified.

        Issue Links

          Activity

          Hide
          Martin Matula added a comment -

          Are you using the version of Jersey shipped with GlassFish or are you including different Jersey jars in your war file?

          Show
          Martin Matula added a comment - Are you using the version of Jersey shipped with GlassFish or are you including different Jersey jars in your war file?
          Hide
          cowwoc added a comment -

          I am using Jersey 1.6 (in my WAR) and <class-loader delegate="false"/> to get Glassfish 3.0.1 to use it.

          Show
          cowwoc added a comment - I am using Jersey 1.6 (in my WAR) and <class-loader delegate="false"/> to get Glassfish 3.0.1 to use it.
          Hide
          Martin Matula added a comment -

          I see - that is the reason for the issue. Unfortunately running multiple different versions of Jersey in GlassFish does not work well at the moment and brings this type of issues. We are trying to address this for the next release of GlassFish by a better OSGi-ification.

          Show
          Martin Matula added a comment - I see - that is the reason for the issue. Unfortunately running multiple different versions of Jersey in GlassFish does not work well at the moment and brings this type of issues. We are trying to address this for the next release of GlassFish by a better OSGi-ification.
          Hide
          cowwoc added a comment -

          Is there a workaround for this issue? I am only running one webapp in Glassfish and it is throwing this exception.

          Show
          cowwoc added a comment - Is there a workaround for this issue? I am only running one webapp in Glassfish and it is throwing this exception.
          Hide
          cowwoc added a comment -

          I found a workaround but it's very slow:

          1) Deploy the new webapp, Glassfish will throw the aforementioned exception
          2) Restart Glassfish
          3) The new webapp is deployed properly

          The problem with the workaround is that every time I make a change I have to wait 30 seconds the deploy and restart to take effect. Please fix this bug "soon" (tm)

          Show
          cowwoc added a comment - I found a workaround but it's very slow: 1) Deploy the new webapp, Glassfish will throw the aforementioned exception 2) Restart Glassfish 3) The new webapp is deployed properly The problem with the workaround is that every time I make a change I have to wait 30 seconds the deploy and restart to take effect. Please fix this bug "soon" (tm)
          Hide
          Michal Gajdos added a comment -

          Are you still facing this issue? The WriterUtil works a little bit different now, but there still may be an issue of using different Jersey 1.x versions in GF that is bundled in GF.

          Show
          Michal Gajdos added a comment - Are you still facing this issue? The WriterUtil works a little bit different now, but there still may be an issue of using different Jersey 1.x versions in GF that is bundled in GF.
          Hide
          cowwoc added a comment -

          I am no longer using Glassfish with Jersey 1.0 (I switched to Jetty) and it's my understanding that it is impossible to swap Jersey versions in Glassfish 2.0 (a step backwards in my view but whatever).

          As such, either you need to test this on your end (try swapping Jersey 1.x versions under Glassfish), find a new user who is interested in this issue, or close it as WON'T FIX.

          Show
          cowwoc added a comment - I am no longer using Glassfish with Jersey 1.0 (I switched to Jetty) and it's my understanding that it is impossible to swap Jersey versions in Glassfish 2.0 (a step backwards in my view but whatever). As such, either you need to test this on your end (try swapping Jersey 1.x versions under Glassfish), find a new user who is interested in this issue, or close it as WON'T FIX.
          Hide
          Michal Gajdos added a comment -

          OK, thank you for your comment. Resolving as WON'T FIX.

          Show
          Michal Gajdos added a comment - OK, thank you for your comment. Resolving as WON'T FIX .

            People

            • Assignee:
              Michal Gajdos
              Reporter:
              cowwoc
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                0m
                Logged:
                Time Not Required
                1m