users@glassfish.java.net

Re: Jersey, META-INF/services files, delegate=false, and GF v3 preview

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Wed, 24 Jun 2009 10:56:43 -0700

On 06/24/09 01:11 AM, Paul Sandoz wrote:
> Hi,
>
> GF v3 preview comes installed with Jersey 1.1.0-ea.
>
> If i create a web app with the Jersey 1.1.1-ea-SNAPSHOT jars in the
> war WEB-INF/lib and set the
>
> <class-loader delegate="false"/>
>
> in the WEB-INF/sun-web.xml then deploy to GF v3, then i find that
> Jersey 1.1.1-ea-SNAPSHOT is also loading the META-INF/services files
> from Jersey 1.1.0-ea. Is that expected behavior ?
>
>
> I found this out recently because we made some changes that resulted
> in modifcations to some META-INF/service files. When I deploy such an
> app (as described above) i get some exceptions thrown by Jersey in the
> log (see end of email).
>
> These exceptions can only occur if a class cannot be loaded from a
> META-INF/services file, and that can only occur if it is including an
> 1.1.0-ea version of a META-INF/services file.
>
> Note that this currently does not affect the running of the
> application, since the changes made are such that it is the case.
>
> But future changes may result in very odd/broken behavior if a
> developer attempts to use a later version on Jersey, installed in the
> war, that the version installed in GF.

Note that the return value of java.util.ServiceLoader#load is an
iteration over the
result of a call to ClassLoader#getResources.

The only effect of setting "delegate" to false is that any local
matching resources will appear
*first* in the returned Enumeration, but it does not mean that any
matching resources higher
up in the class loader delegation chain will be omitted from the
Enumeration.


Jan


>
> Paul.
>
>
> [#|2009-06-19T17:51:41.483+0200|SEVERE|glassfish|com.sun.jersey.core.spi.component.ProviderFactory|_ThreadID=17;_ThreadName=Thread-1;|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:572)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:386)
>
> 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:243)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>