Today we encountered a classloading problem in JBoss AS 7.1.1 while using JAX-WS. JBoss uses CXF as its JAX-WS implementation and CXF in turn depends on Woodstox as its default StAX implementation. The problem was that JBoss failed to load Woodstox now and then when parsing SOAP requests. The full stacktrace:
10:34:57,037 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/xxxx-ws].[xxxxWebservice]] (http--0.0.0.0-8080-1) Servlet.service() for servlet xxxxWebservice threw exception: java.lang.NoClassDefFoundError: com/ctc/wstx/io/DefaultInputResolver at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:609) [woodstox-core-asl-4.1.1.jar:4.1.1] at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:316) [woodstox-core-asl-4.1.1.jar:4.1.1] at _redirected.XMLInputFactory.createXMLStreamReader(_XMLInputFactory.java:139) [jboss-modules.jar:1.1.1.GA] at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1176) [cxf-common-utilities-2.4.6.jar:2.4.6] at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104) [cxf-rt-core-2.4.6.jar:2.4.6] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) [cxf-api-2.4.6.jar:2.4.6] at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-rt-core-2.4.6.jar:2.4.6] at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) [cxf-rt-transports-http-2.4.6.jar:2.4.6] at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91) at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:169) at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) [cxf-rt-transports-http-2.4.6.jar:2.4.6] at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108) [cxf-rt-transports-http-2.4.6.jar:2.4.6] at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final] at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135) at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi-2.0.3.GA.jar:2.0.3.GA] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
It looked like a Heisenbug at first but after a while we noticed a pattern: It only seemed to occur after undeploying and then redeploying the application on a running server. The issue didn’t occur after cold server restarts as well as hot (re)deployments. We needed an explicit undeployment first.
Solution
The CXF module in JBoss is missing an import of Woodstox. Open $JBOSS_HOME/modules/org/apache/cxf/main/module.xml and add the following import to the list of dependencies:
<dependencies>
<module name="org.codehaus.woodstox" />
</dependencies>
I believe this to be a bug in JBoss AS7 and will file a bug report shortly.