Larry,
It is unfortunate, but at GFv3.0.1, the rest-service.jar module provides
some
message body readers/writers which are picked by Jersey 1.5-SNAPSHOT
runtime
when deploying your application.
The only workaround i can think of at the moment is to follow the advice
[1].
You will need to bundle jersey jars with your web application (in maven,
just set the jersey
dependencies scope to compile), set class loading delegation to false in
sun-web.xml
and allow overriding javax.ws.rs classes by setting the jvm option as
suggested
in the the docs:
----8<----
To override the version of Jersey distributed in GlassFish with a
version of Jersey distributed in a war file ensure that class loader
delegation is set to false in WEB-INF/sun-web.xml or
WEB-INF/glassfish-web.xml. For example:
<sun-web-app error-url="">
<context-root>/context</context-root>
<class-loader delegate="false"/>
</sun-web-app>
In the GlassFish admin console, go to Configuration->JVM Settings,
switch to the JVM Options tab and add the following option:
-Dcom.sun.enterprise.overrideablejavaxpackages=javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext
---->8----
This should be "fixed" in GFv3.1, as the rest-service.jar module there
does not use
the META-INF/services mechanism to configure its message body
readers/writers.
HTH,
~Jakub
[1]
https://jersey.dev.java.net/nonav/documentation/1.5-SNAPSHOT/glassfish.html#d0e4147
On 10/18/2010 05:32 PM, Larry Touve wrote:
>
> Jakub,
>
> Here's the info. This thread got split, so most of the original info
> got lost. I've seen this error in two cases -- one during activation
> of an OSGi bundle that contained a jersey client, and the other
> occurred during deployment of a war file that contained a jersey
> client. I'm still investigating the circumstances surrounding the
> first case. For the second case, I have a simple jersey client that
> contains the following class:
>
> @Path("/eventcontrol")
>
> public class ExerciseController
>
> {
>
> private static final Logger logger =
> Logger.getLogger("ExerciseController");
>
> private WebResource resource = null;
>
> public ExerciseController()
>
> {
>
> }
>
> @PostConstruct
>
> public void readInitParams()
>
> {
>
> try
>
> {
>
> ClientConfig cc = new DefaultClientConfig();
>
> Client client = Client.create(cc);
> ***** This is the line that the exception below occurs on *****
>
> resource = client.resource(base + context);
>
> }
>
> catch (Exception e)
>
> {
>
> logger.log(Level.WARNING, "Error initializing
> configuration", e);
>
> }
>
> }
>
> @GET
>
> @Produces(MediaType.APPLICATION_JSON)
>
> @Path("/state")
>
> public Response getState()
>
> {
>
> String response = { build the response string here...}
>
> return Response.ok(response, MediaType.APPLICATION_JSON).build();
>
> }
>
> }
>
> My web.xml has the following:
>
> <servlet>
>
> <servlet-name>Jersey Web Application</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
>
> <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
>
> </init-param>
>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.classnames</param-name>
>
> <param-value>ExerciseController</param-value>
>
> </init-param>
>
> <load-on-startup>1</load-on-startup>
>
> </servlet>
>
> I can compile, build, and deploy the war file to a Glassfish 3.0.1
> domain that has the jersey 1.5-SNAPSHOT bundles installed. When I hit
> the URL the first time, I see the following:
>
> [#|2010-10-18T08:42:48.296-0400|SEVERE|glassfish3.0.1|com.sun.jersey.spi.inject.Errors|_ThreadID=25;_ThreadName=Thread-1;|The
> following errors and warnings have been detected with resource and/or
> provider classes:
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.TreeNodeHtmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.CommandResourceGetResultHtmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.CommandResourceGetResultXmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultListHtmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.OptionsResultXmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultListJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.OptionsResultJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.FormWriter.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.StringResultHtmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultXmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.StringResultJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultHtmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.CommandResourceGetResultJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.TreeNodeXmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.TreeNodeJsonProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.GetResultListXmlProvider.uriInfo
>
> SEVERE: Missing dependency for field: protected
> javax.ws.rs.core.UriInfo
> org.glassfish.admin.rest.provider.StringResultXmlProvider.uriInfo|#]
>
> [#|2010-10-18T08:42:48.313-0400|WARNING|glassfish3.0.1|ExerciseController|_ThreadID=25;_ThreadName=Thread-1;|Error
> initializing configuration
>
> com.sun.jersey.spi.inject.Errors$ErrorMessagesException
>
> at
> com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
>
> at
> com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:137)
>
> at
> com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:203)
>
> at
> com.sun.jersey.api.client.Client.<init>(Client.java:187)
>
> at
> com.sun.jersey.api.client.Client.<init>(Client.java:170)
>
> at
> com.sun.jersey.api.client.Client.create(Client.java:660)
>
> at
> ExerciseController.readInitParams(ExerciseController.java:59)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
>
> at
> com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:182)
>
> at
> com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:182)
>
> at
> com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:144)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:225)
>
> at
> com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:69)
>
> at
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
>
> at
> com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1357)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1289)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1239)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
>
> at
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)
>
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:519)
>
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:706)
>
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
>
> at
> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
>
> 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:619)
>
> |#]
>
> Larry Touve
>
> Principal Software Architect
>
> Potomac Fusion, Inc. <http://www.potomacfusion.com/>
>
> 14130 Sullyfield Circle, Suite E
>
> Chantilly, VA 20151
>
> (703) 378-6032 x437
>
> *From:* Jakub.Podlesak_at_Sun.COM [mailto:Jakub.Podlesak_at_Sun.COM]
> *Sent:* Monday, October 18, 2010 7:48 AM
> *To:* users_at_jersey.dev.java.net
> *Cc:* Larry Touve
> *Subject:* Re: [Jersey] Re: OSGI Startup Errors
>
> Hi Larry,
>
> Could you please provide some more details on your use case?
> I understood you want to build a client instance in your bundle activator.
> How you utilize this client further? How you control bundle activation?
> In GlassFish, bundles are not activated by default.
> A simple use case would be the most useful,
> please feel free to send it privately if you do not want
> to send to the whole list.
>
> Thanks,
>
> ~Jakub
>
> On 10/16/2010 05:33 AM, Larry Touve wrote:
>
> Is there any way to work around this issue?
>
> thanks,
>
> Larry
>
> > Hi Larry,
>
> >
>
> >The REST admin service message body readers/writers declared in
> META-INF/services files of the admin module are getting picked up by
> your bundle. I do not know why it does that. We would need Jakub to
> help investigate further.
>
> >
>
> >FWIW for 3.1 the REST admin service no longer uses META-INF/services
> files.
>
> >
>
> >Paul.
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.862 / Virus Database: 271.1.1/3203 - Release Date:
> 10/17/10 14:33:00
>