2

Jersey jars included in war :- jersey-client-1.17.jar jersey-core-1.17.jar jersey-json-1.17.jar jersey-multipart-1.17.jar jersey-server-1.17.jar jersey-servlet-1.17.jar

Application web.xml configuration :-

<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>MyPackage containing services</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>Filter Class</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>

When we generate a EAR of our application, the package which contains the rest services, are placed inside a jar file and this jar file is in web-inf/lib folder.

Errors :- When we start the WebSphere, we are getting following exceptions.

 Exception:com.sun.jersey.api.container.ContainerException SourceId:com.ibm.ws.webcontainer.servlet.ServletInstance.init ProbeId:181 Reporter:com.ibm.ws.webcontainer.servlet.ServletWrapperImpl@f574a14e
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)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765)
    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489)
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319)
    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
    at javax.servlet.GenericServlet.init(GenericServlet.java:161)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:342)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1366)
    at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:627)
    at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:593)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:422)
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2195)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5387)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5603)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2200)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:435)
    at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:378)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:126)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:984)
    at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)

Things we tried :-

  • We thought IBM websphere's JAX-RS internal implementation is causing some issues with JERSEY rest, so we added a JVM parameter "com.ibm.websphere.webservices.DisableIBMJAXWSEngine" and set its value to true.

  • Also we tried changing the class loader policy of WebSphere from "Parent Class Loader First " to "local class loader first(parent last)".

  • But still, during startup, we were getting below message :- "The ResourceConfig instance does not contain any root resource classes ". So basically, it is not able to get root resource classes, which are present in package mentioned in web.xml.

  • So we deleted one of classes from the package, so that during startup it will throw some class not found exception, but the same did not occur.

Has anyone faced the similar issue before ? Please let us know, as we have spent lot of time analysing this issue and we didn't find any specific solution.

Rohit
  • 146
  • 1
  • 5
  • Check if your `application.xml` and `web.xml` are in latest versions (6 and 3.0). If they are too old (Java EE 1.4) then contents will not be scanned for annotations. – Gas Apr 16 '15 at 16:21
  • Hi, we are currently using servlet version 2.3 ? Is it really causing the issue ? – Rohit Apr 17 '15 at 13:14
  • 1
    I also tried creating share lib by following instructions at https://www.ibm.com/developerworks/community/forums/html/topic?id=986afce3-d94d-43ba-8bdd-31547bfb0c77, but then we were getting CDI exceptions, stating that application is not CDI enabled. – Rohit Apr 17 '15 at 13:58
  • Yes, you need to update to 2.5 for annotations to be enabled, and 3.0 for CDI.For shared library solution check this - [JAX-RS Jersey 2.10 support in Websphere 8](http://stackoverflow.com/questions/24684958/jax-rs-jersey-2-10-support-in-websphere-8/24713878#24713878). – Gas Apr 17 '15 at 15:46
  • Thanks. Will surely check by updating it to 2.5. – Rohit Apr 17 '15 at 17:55
  • Rohit, you can use the same procedure for 1.17 – Gas Apr 18 '15 at 08:56
  • We changed the web.xml and set the version to 2.5. But now we are getting exceptions for ServletContainerInitializer. Following is the exceptions :- com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer not a subtype – Rohit Apr 20 '15 at 13:36
  • Did you create isolated shared library for Jersey jars? Also make sure you are not including Java EE jars in your application (like servlet.jar, jst.jar etc). – Gas Apr 20 '15 at 13:50
  • I have created shared library for jersey jars. Currently I am having servlet-api.jar in my web-inf/lib folder. Is that jar causing the problem ? – Rohit Apr 20 '15 at 13:55
  • Yes, it may. But it shouldn't be there anyway so remove that from WEB-INF/lib. Check, if your library is marked as isolated. – Gas Apr 20 '15 at 14:11
  • Event after removing the above jar, i am getting following error :- com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer not a subtype – Rohit Apr 21 '15 at 07:19
  • You must have some other conflicting jars there. Add list of jars you have in web-inf/lib and in shared library to the question. – Gas Apr 21 '15 at 08:30
  • Hi Gas, Currently i am having almost 170 jars present. It will be very difficult to post all the names of jars, i will trying to post the names of jars which are relevant. – Rohit Apr 21 '15 at 09:35
  • Better create just a small hello app with only JAX-RS jars and make sure it runs correctly. – Gas Apr 21 '15 at 10:50
  • Not sure this applies to your case, but WAS 8.5.5 has a problem with running Jersey 1.x – https://developer.ibm.com/answers/questions/169221/packagesresourceconfig.html – ᄂ ᄀ Apr 25 '15 at 14:15
  • Yes Gas. We deployed a test rest application on WAS 8.5.5, and it didn't worked. The same worked on 8.0.0.9. Anyway thanks a lot for help. Hope it gets fixed soon in 8.5.5 – Rohit Apr 28 '15 at 15:52
  • We have converted all the jersey based rest services to spring rest services...we have removed all the dependencies on jersey from our application. – Rohit Jan 26 '17 at 18:39

0 Answers0