Question

I am trying to deploy a rest web service in WAS 8.0

The application EAR is getting installed successfully.

However, both on publishing as well as on hitting the service from web browser after publishing, I am getting below error:

[3/13/14 13:42:20:652 IST] 00000024 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper run SRVE8052E: Logging ClassNotFoundException
                             java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.apache.cxf.transport.servlet.CXFServlet
at java.beans.Beans.instantiate(Beans.java:190)
at java.beans.Beans.instantiate(Beans.java:75)
at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1471)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1460)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1358)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:982)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3751)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
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:1690)

However, the jar containing the class viz. cxf-rt-transports-http-2.7.4.jar is present inside lib directory of the WAR inside the EAR installed.

What is the cause of the issue ?

How can I resolve it ?

Update: My web.xml is as below:

<web-app>
<display-name>MyService</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <display-name>CXF Servlet</display-name>
    <servlet-class>
        org.apache.cxf.transport.servlet.CXFServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

</web-app>
Was it helpful?

Solution

I see that you mentioned the word "publish", which hints that you might be using Eclipse, or possibly IBM's RAD or even MyEclipse Blue.

In case that's true, read on...

While your .ear, generated by m2e/Maven, may have the .jar file present in the .war file, there's a chance that the .ear and .war file, generated by m2e-wtp, is missing the .jar file. m2e-wtp's generated .ear file is what's used when you publish/republish your application to WAS from within Eclipse/RAD/MyEclipse Blue.

Try removing the app from your local WAS, finding the location of that m2e-wtp-generated .ear file, and deleting it. From there, m2e-wtp should automatically generate a fresh .ear file if you clean your project (all associated pom, ear, war, etc.)

When you publish your app, it should find the class. I've had the same problem happen to me in the past. My suggestion has fixed the problem.

Other than that, you may need to set the Classloader Policy to PARENT_LAST and check that you're using a single classloader for the entire app (the 2nd set of radio buttons below the Classloader Policy radio buttons) within the WAS admin console. However, I doubt that the Classloader Policy is the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top