I have been trying to deploy and run a Jersey2 based REST application on WebSphere ND 8.5. However, it refuses to start up properly and gives the following error:
com.ibm.ws.webcontainer.servlet.ServletWrapper run SRVE8052E: Logging ClassNotFoundException java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
I tried going through most of the related questions, but none of it was helpful in figuring out the problem.
Some of the links I tried:
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer - Accepted answer talks about ensuring the jars are present in WEB-INF/lib. My project is already a Maven project, and dependencies are correctly bundled:
JAX-RS Jersey 2.10 support in Websphere 8 - Setting com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine to true in JVM properties did not help
- WebSphere 8.5.5.9 with Jersey 2.25 - Has same suggestions as above
As of now, on my local setup the EAR file runs correctly, on a Liberty profile server (embedded in Eclipse). Maven build works fine, and libraries are copied correctly.
One discrepancy I am aware of is that I am using Jersey2.xx, still with the entries in web.xml. But I am not sure how that could cause a ClassNotFoundException.
web.xml for reference:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>MyRestApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>My REST Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.vai.app.rest.main.MyRestApplication</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.vai.app.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>My REST Application</servlet-name>
<url-pattern>/rest/api/*</url-pattern>
</servlet-mapping>
</web-app>
The weirder thing is this application was at least starting up without this error couple of days back, before an admin "manually removed old files" before re-installing this app on server. This makes me think there was some configuration which got removed/reset during that process which caused this.
How can I make this EAR run without getting this exception on WAS ND 8.5?
Edit: adding full stack trace. I have set the class loading as PARENT_LAST, so I guess it should be using the module's class loader?
[11/22/19 8:40:19:570 CST] 000000b9 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper run SRVE8052E: Logging ClassNotFoundException
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:332)
at com.sun.beans.finder.ClassFinder.findClass(ClassFinder.java:87)
at com.sun.beans.finder.ClassFinder.findClass(ClassFinder.java:122)
at java.beans.Beans.instantiate(Beans.java:220)
at java.beans.Beans.instantiate(Beans.java:88)
at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1489)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1478)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1376)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1027)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4047)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1016)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:213)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1187)
at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:694)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1833)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)