11

My webapp contains a library which contains a class annotated with @javax.ws.rs.ext.Provider. If this class is present, my webapp (deployed as a WAR within an EAR) fails to start with the following error:

<19-Jun-2014 14:41:50 o'clock BST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1403185262187" for task "2". Error is: "weblogic.application.ModuleException: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes."
weblogic.application.ModuleException: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:213)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:208)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        Truncated. see log file for complete stacktrace
Caused By: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
        at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1331)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168)
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774)
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770)
        Truncated. see log file for complete stacktrace

I'm not using jersey at all, I'm not using any jax-rs services, and my web.xml contains no jersey related servlets. I don't understand why weblogic initialises jersey and scans jars in my application for jaxrs related stuff.

Most of the information I can find on the internet relating to this results in people configuring their jersey servlet differently. But I don't have one to configure...

I don't control the offending library, so removing the class is not an option.

So, how can I tell weblogic not to scan my classes when it initialises jersey?

Note that this happened after changing my web.xml to servlet 3.0 instead of 2.4. If I change it back to 2.4, everything is fine.

I'm using weblogic 12.1.2.0 (12c).

Update: turns out that JAX-RS scanning is a key feature of Javaee 6 - the whole idea is that you put your annotated classes in your webapp and you don't need to do any configuration to have them exposed as a REST webservice.

stripybadger
  • 4,539
  • 3
  • 19
  • 26
  • 1
    I just want to ask if a relevant solution to the problem was found or not. Can you suggest a work around because I am facing same issue. :( Can we tell Weblogic to not look for Jersey jars while using servlet version to 3.0 in web.xml?? – JavaBeigner Sep 09 '14 at 09:40
  • Any update about my issue? – JavaBeigner Sep 10 '14 at 05:56

2 Answers2

0

This page documents the names of the JAR and WAR files that WebLogic uses for loading Jersey. You could rename or remove those files and just prevent WebLogic from loading them outright.

It's been unclear to me whether WebLogic actually uses those JAR files. From everything I have read, WebLogic provides JARs in the deployable-libraries as pre-built shared libraries for use in web applications and not for use by WebLogic Server directly.

Erik Gillespie
  • 3,929
  • 2
  • 31
  • 48
  • 1
    My webapp is something I give out to customers, so I'd be asking them to remove jars from their weblogic instances, which I think they'd be pretty reluctant to do. And if I'm going to go to this level of hackery then it would probably be easier to remove this file from the jar as part of the build (though this is what I'm trying to avoid). – stripybadger Jun 23 '14 at 07:24
  • weblogic 12c behaves very different then 11g (10.3.6) – Kalpesh Soni May 02 '15 at 18:39
0

I have a clue to disable the jersey scanning by setting a property jersey.config.disableAutoDiscovery, but it does not work for me yet. See Configuring the Classpath Scanning for more details.

banterCZ
  • 1,551
  • 1
  • 22
  • 37