<< Back to previous view

[JERSEY-660] NPE in com.sun.jersey.core.impl.provider.header.WriterUtil.appendQuotedIfWhiteSpaceOrQuote(WriterUtil.java:59) Created: 24/Feb/11  Updated: 05/Nov/13  Resolved: 05/Nov/13

Status: Resolved
Project: jersey
Component/s: core
Affects Version/s: 1.5
Fix Version/s: 1.18

Type: Bug Priority: Major
Reporter: cowwoc Assignee: Michal Gajdos
Resolution: Won't Fix Votes: 0
Remaining Estimate: 0 minutes
Time Spent: 1 minute
Original Estimate: 3 hours
Environment:

Netbeans 6.9.1
Glassfish 3.0.1


Issue Links:
Dependency
depends on GLASSFISH-13236 [jersey] Jersey bundles optionally de... Resolved
depends on GLASSFISH-16518 Jersey: Allow regular users to run di... Open
depends on GLASSFISH-13165 Jersey uses DynamicImport-Package: * Open
Tags: incomplete
Participants: cowwoc, Martin Matula and Michal Gajdos

 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.



 Comments   
Comment by Martin Matula [ 12/May/11 01:32 AM ]

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

Comment by cowwoc [ 14/May/11 11:47 AM ]

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

Comment by Martin Matula [ 16/May/11 07:56 AM ]

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.

Comment by cowwoc [ 10/Jul/11 12:01 AM ]

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

Comment by cowwoc [ 10/Jul/11 12:51 AM ]

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)

Comment by Michal Gajdos [ 04/Nov/13 02:54 PM ]

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.

Comment by cowwoc [ 05/Nov/13 09:08 PM ]

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.

Comment by Michal Gajdos [ 05/Nov/13 09:25 PM ]

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

Generated at Wed Apr 23 21:15:53 UTC 2014 using JIRA 4.0.2#472.