LinkageError: loading contraint violation

3.4k Views Asked by At

I have seen the other linkage errors but none of them says what can be done with the jars. When I deploy my application in Jboss it works fine, but when I deploy my application to websphere I am having this linkage errors. A similar issue can be found here: LinkageError when calling webservice method but not sure what to do to fix it

Mainly it loaded from com/ibm/oti/vm/BootstrapClassLoader and com/ibm/ws/classloader/CompoundClassLoader with the shared class javax/xml/soap/SOAPFault

Caused by: java.lang.LinkageError: loading constraint violation: loader "com/ibm/oti/vm/BootstrapClassLoader@dda62209" previously initiated loading for a different type with name "javax/xml/soap/SOAPFault" defined by loader "com/ibm/ws/classloader/CompoundClassLoader@fdebcda2"
        at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
        at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:63)
        at javax.xml.ws.soap.SOAPFaultException.<init>(SOAPFaultException.java:78)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
        at com.sun.proxy.$Proxy118.collectionsInquiryV2(Unknown Source)

What I have is jsp calling a webservice. From the message the only jars I saw is from axis.jar with contains the class javax/xml/soap/SOAPFault

does it mean I need to remove the SOAPFault.class from axis.jar? (it does not work tried and other webservice would fail if this was removed)

1

There are 1 best solutions below

3
On

Do you have a SOAP API jar in your application? The "loading constraint violation" LinkageError generally implies duplicate visibility to a class through two different class loaders. What I'm guessing is happening here based on the stack is that your application has the SOAP API but not the JAX-WS API. When that JAX-WS class references the SOAP class, that means that the classes in your app can "see" the SOAP API from two different loaders - directly, in the local class loader, and indirectly through the JAX-WS API.

Simplest answer is just to get rid of any SOAP API jar(s) in your app - you can just rely on the copy in the server, unless you have a really specific version need. Alternately, you could add a JAX-WS API jar to the application package, so the application loads its own copy of the API rather than pulling it from the server.