dev@jersey.java.net

Re: [Jersey] classloading issue in Glassfish when older version jersey-bundle.jar is present

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 25 Sep 2009 10:06:44 +0200

Hi Edward,

Are you using GF v2.1.1?

If so the only reliable way is to upgrade GF v2 via the the update
center to use the latest version of Jersey which will be version 1.1.2
(unfortunately the GF v2 update center cannot support multiple
versions of stuff).

You could try setting class loader delegation to false in the sun-
web.xml, that might work. However, in general that solution is not
guaranteed to work in all cases. Unfortunately it is not possible to
have two different versions of Jersey within the same JVM and
guarantee they will work unless they are completely isolated in terms
of class loading. The main issue is with the META-INF/services files.

Paul.

On Sep 25, 2009, at 2:17 AM, Edward Chou wrote:

> Okay thanks.
>
> It might not be possible for me to update the jersey.jar in the
> "glassfish/lib" directory, for various other reasons. So I guess my
> only choice is to not packaging jersey.jar in my own application,
> and just have use the older version of jersey.jar from Glassfish
> installation. /cry
>
>
>
> Craig McClanahan wrote:
>> Edward Chou wrote:
>>> Hi Paul,
>>>
>>> I am using a version of Glassfish that is packaging "jersey-
>>> bundle-1.0.3.1.jar" in the "glassfish/lib" directory. However, I
>>> am deploying a Jersey application that also packages a new version
>>> of "jersey-bundle-1.1.1-ea.jar" in its classpath. As a result, I
>>> am getting the below exception in the server.log about
>>> IllegalAccessException. If I remove the jersey-bundle.jar from
>>> the "glassfish/lib" directory, then I don't see this exception.
>> Hmm ... trying to mix revs of the same package is almost always
>> going to fail with problems like this.
>>>
>>> My question is, do you know anyway to get around this problem,
>>> without having to update/remove the "glassfish/lib" directory
>>> Jersey jar? Anyway to force my Jersey application to use the
>>> newer Jersey jar that is packaged in the application?
>>>
>> Have you tried just replacing the glassfish/lib/jersey-
>> bundle-1.0.3.1.jar with your jersey-bundle-1.1.1-ea.jar, and then
>> *not* including the Jersey jar in your webapp? (No guarantees that
>> you won't run into other incompatibilities if Glassfish does not
>> know how to deal with Jersey 1.1, but at least you won't have two
>> versions of the same classes on the classpath at the same time.)
>>
>> Craig
>>
>>> Thanks,
>>> Edward
>>>
>>> [#|2009-09-24T14:23:49.121-0700|SEVERE|sun-appserver2.1|
>>> com.sun.jersey.core.spi.component.ProviderFactory|
>>> _ThreadID=26;_ThreadName=http9696-
>>> WorkerThread(0);_RequestID=5eb1b7ea-6265-438c-9270-b01b9ea4b2e1;|
>>> The provider class, class
>>> com.sun.jersey.json.impl.provider.entity.JSONObjectProvider, could
>>> not be instantiated. Processing will continue but the class will
>>> not be utilized
>>> java.lang.IllegalAccessException: Class
>>> com.sun.jersey.core.spi.component.ComponentConstructor can not
>>> access a member of class
>>> com.sun.jersey.json.impl.provider.entity.JSONObjectProvider with
>>> modifiers ""
>>> at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
>>> at java.lang.Class.newInstance0(Class.java:349)
>>> at java.lang.Class.newInstance(Class.java:308)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .component
>>> .ComponentConstructor._getInstance(ComponentConstructor.java:152)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .component
>>> .ComponentConstructor.getInstance(ComponentConstructor.java:140)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .component
>>> .ProviderFactory.__getComponentProvider(ProviderFactory.java:159)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .component
>>> .ProviderFactory.getComponentProvider(ProviderFactory.java:130)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi.component.ProviderServices.getComponent(ProviderServices.java:
>>> 190)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .component
>>> .ProviderServices.getProvidersAndServices(ProviderServices.java:120)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core
>>> .spi
>>> .factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:171)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:
>>> 146)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .server
>>> .impl
>>> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:
>>> 609)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .server
>>> .impl
>>> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:
>>> 419)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi
>>> .container.servlet.ServletContainer.initiate(ServletContainer.java:
>>> 377)
>>> at com.sun.jersey.spi.container.servlet.ServletContainer
>>> $InternalWebComponent.initiate(ServletContainer.java:242)
>>> at
>>> com
>>> .sun
>>> .jersey.spi.container.servlet.WebComponent.load(WebComponent.java:
>>> 455)
>>> at
>>> com
>>> .sun
>>> .jersey.spi.container.servlet.WebComponent.init(WebComponent.java:
>>> 178)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
>>> 281)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
>>> 442)
>>> at javax.servlet.GenericServlet.init(GenericServlet.java:270)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:327)
>>> at
>>> com
>>> .sun
>>> .grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:
>>> 268)
>>> at
>>> com
>>> .sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
>>> 165)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:
>>> 185)
>>> at
>>> com
>>> .sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
>>> 165)
>>> at
>>> com
>>> .sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
>>> 726)
>>> at
>>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:615)
>>> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:
>>> 895)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:162)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .DefaultProtocolChain
>>> .executeProtocolFilter(DefaultProtocolChain.java:136)
>>> at
>>> com
>>> .sun
>>> .grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
>>> at
>>> com
>>> .sun
>>> .grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
>>> at
>>> com
>>> .sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
>>> 76)
>>> at
>>> com
>>> .sun
>>> .grizzly
>>> .ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
>>> at
>>> com
>>> .sun
>>> .grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
>>> 57)
>>> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:
>>> 303)
>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>>> at java.util.concurrent.ThreadPoolExecutor
>>> $Worker.runTask(ThreadPoolExecutor.java:885)
>>> at java.util.concurrent.ThreadPoolExecutor
>>> $Worker.run(ThreadPoolExecutor.java:907)
>>> at java.lang.Thread.run(Thread.java:619)
>>> |#]
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>