2
votes

I have a project (say myproject) in which I have hosted a CXF RESTful service and CXF WS/SOAP service, and running on JBoss (6.0.0.FINAL). The RESTful interface is used by all of our internal systems, and the SOAP interface is used by the third party systems (as a callback interface)

Following URLs are working fine.

  • REST URL: http://localhost:8080/myproject/internal/someOperation (content-type: application/json and POST body)

  • SOAP WSDL: http://localhost:8080/myproject/cbsoap?wsdl

Now my problem is that actual SOAP calls are not successful. I use SOAPUI to try the SOAP calls but just to able to query the WSDL. I am getting the following error:-

javax.servlet.ServletException: Servlet execution threw an exception
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)

root cause

java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.cxf.jaxb.attachment.JAXBAttachmentUnmarshaller.getAttachmentAsDataHandler(Ljava/lang/String;)Ljavax/activation/DataHandler;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller, and its superclass loader (instance of ), have different Class objects for the type r used in the signature
    org.apache.cxf.jaxb.JAXBDataBase.getAttachmentUnmarshaller(JAXBDataBase.java:78)
    org.apache.cxf.jaxb.io.DataReaderImpl.createUnmarshaller(DataReaderImpl.java:123)
    org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
    org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:191)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:164)
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
2
This sounds really scary: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.cxf.jaxb.attachment.JAXBAttachmentUnmarshaller.getAttachmentAsDataHandler(Ljava/lang/String;)Ljavax/activation/DataHandler;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller, and its superclass loader (instance of ), have different Class objects for the type r used in the signatureDonal Fellows
I mean, different Class objects? Definitely sounds like class loader games gone wrong. (Not enough experience with debugging these things to help.)Donal Fellows
My understanding is that the JAXBAttachmentUnmarshaller class is loaded twice (or already), and the getAttachmentAsDataHa‌​ndler method signatures are different. I am not sure if that makes sense. But need to get rid of one of them but don't know which one and how.Higher Kinded Type
@DonalFellows The issue here is that JBoss comes with Java 6+ and javax.activiation.DataHandler is actually included in standard Java 6. When mixing it with different classloaders there is no way to be able to delegate the EAR/WAR to use it's own javax.activation.DataHandler since its a system level class. Hence the LinkageError. If it were a JAR included for JBoss the parent-last mechanism would work.John Vint
@VivekRagunathan The reason why it is probably not JAXBAttachmentUnmarshaller is because JAXBAttachmentUnmarshaller is not a system class (it is not included with the Java runtime) so no LinkageError should occurJohn Vint

2 Answers

5
votes

LinkageError is JBoss is generally caused by your app packaging its own copies of certain libraries that JBoss considers restricted. These are usually things in the java.* and javax.* packages.

Looking at your stack trace, I'd guess that the culprit is javax.activation.DataHandler. Check your app's bundled JAR files, make sure there's nothing like that in them. If there is, then remove it.

It may not be javax.activation.DataHandler, but may be something it in turn depends on.

0
votes

I finally solved the problem but it is really weird.

  1. I added cxf-rt-frontend-jaxws and cxf-bundle-rs as dependencies and mark some exclusions -> jetty-server, gernomino-servlet.
  2. I had the beans.xml under WEB-INF folder but had to place it under src/main/resources. The beans.xml is expected to be under the classpath, instead of WEB-INF.

Thanks for your responses.