1
votes

I have a webapp running JAX-RS web services using the Jersey implementation. The target app server is a WebLogic 12c whose default JAXRS implementation is Jersey v1.9.

1) when run on Jetty (6.1.26) with jersey-server-1.9 dependency, everything is fine.

2) when run on WebLogic 12c with jersey-core.jar + jersey-server.jar (v1.9) jars both embedded in the WEB-INF/lib of my war, it is also working.

2) when run on WebLogic 12c with the same war amputed from these 2 jars (assuming there are not needed as already provided by the weblogic Java EE stack), it does NOT work anymore. I got the following error:

"weblogic.application.ModuleException: [HTTP:101216]Servlet: "jersey-servlet" failed to preload on startup in Web application: "cachede-newgen.war". com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. at com.sun.jersey.server.impl.application.RootResourceUriRules.(RootResourceUriRules.java:99)"

Needless to say the Jersey version is exactly identical in all three cases:

"Apr 24, 2013 4:10:24 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'"

It sounds again (sight!) like a classpath or classloader issue :-(

Any idea or workaround to solve this issue (taking accound that I do NOT want to repeat jersey jars in every deployed war) ?

3

3 Answers

3
votes

Ok I found the reason :-) - and "better_use_mkstemp" put me on the right direction (many thx!).

The solution consists in adding a reference to the deployed Jersey version in the weblogic descriptor file:

<library-ref>  
    <library-name>jersey-bundle</library-name>  
    <specification-version>1.1.1</specification-version>  
    <implementation-version>1.1.5.1</implementation-version>  
</library-ref>

The strange thing is that, without such ref, the error message (ie "The ResourceConfig instance does not contain any root resource classes") gives the feeling that Jersey is able to start and scan your annotated classes...

NB: Actually, you also need a reference to the JSR-311 api, as explained here: http://theblasfrompas.blogspot.be/2011/03/time-to-deploy-restful-web-service-from.html

1
votes

Have you "deployed" the jersey jar to your server? In the admin console go to Deployables (click Customize the table and uncheck exclude libraries). See if Jersey is listed there. If not, you will need to "deploy" it and target whatever servers you need it on. Then try to redeploy your war file.

Jersey should live in:

wlserver_10.3/common/deployable-libraries

Those shared libraries aren't automatically available to your server until they are targetted to it.

1
votes

Just remove all Jersey jars and add one Jersey Bundle jar it will work. I have faced the same Issue and resolved after adding Jersey Bundle jar into to class path.