1

I am introducing the support of WS-Security with Spring using Apache CXF. Application runs on Weblogic 10.3.6.

Our build.gradle file :-

    compile("org.springframework:spring-web:4.2.6.RELEASE")
    compile("org.springframework:spring-core:4.2.6.RELEASE")
    compile("org.springframework:spring-beans:4.2.6.RELEASE")
    compile("org.springframework:spring-jms:4.2.6.RELEASE")
    compile("org.springframework:spring-orm:4.2.6.RELEASE")
    compile("org.apache.cxf:cxf-rt-transports-http:3.1.6")
    compile("org.apache.cxf:cxf-rt-bindings-soap:3.1.6")
    compile("org.apache.cxf:cxf-rt-frontend-simple:3.1.6")
    compile("org.apache.cxf:cxf-rt-frontend-jaxws:3.1.6")
    compile("org.apache.cxf:cxf-rt-ws-addr:3.1.6")
    compile("org.hibernate:hibernate-core:5.1.0.Final")                     
    compile("commons-lang:commons-lang:2.6")
    compile("org.apache.ws.security:wss4j:1.6.10")
    compile("xalan:xalan:2.7.2")

During the implementation, I encountered the following error :-

    java.lang.ClassNotFoundException: org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor

So I introduced the following dependency to resolve the exception

compile("org.apache.cxf:cxf-rt-ws-security:3.1.6")

However, rebuilding and redeploying the application I encounter the following exception :-

    Caused By: java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Ljavax/xml/stream/XMLEventReader;)Ljava/lang/Object;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type allerImpl.unmarshal(Ljavax/xml/stream/XMLEventReader;)Ljava/lang/Object; used in the signature

I presume this is a ClassLoader issue, with the unmarshal() in class UnmarshallerIml.

I am surprised by introducing compile("org.apache.cxf:cxf-rt-ws-security:3.1.6") I am encountering this exception.

I would very much appreciate any suggestion on the cause and possible solution to this error.

Thank you in advance for your help.

Pete

Pete Long
  • 107
  • 2
  • 11
  • Hi, Have a solution that no longer generates the dreaded "LinkageError", however, I can't give an explanation as why this works. Couple of very helpful links for me were :- https://stackoverflow.com/questions/9997212/how-do-i-resolve-this-weblogic-intermittent-java-lang-linkageerror-what-are-the https://stackoverflow.com/questions/10495254/linkageerror-whilst-trying-to-invoke-cxf-soap-webservice Both helped in understanding the exception message as it was not obvious what it was reporting. CONTINUED BELOW – Pete Long Feb 04 '18 at 16:56
  • In essence, the issue was when I deployed my application in WebLogic, the magical class loading seemed to be identifying two implementation of the XMLEventReader(). In the exception messgage, there is a ref to "instance of ", which indicates the WebLogic System Classloader. So effectively, WebLogic was providing an implementation of XMLEventReader(). So I scanned all the jars in my application WEB-INF\lib folder. three jars made some reference to XMLEventReader. On closer inspection, only one jar actually provided an implementation. CONTINUED BELOW – Pete Long Feb 04 '18 at 17:01
  • The offending jar in my WEB-INF/lib folder was stax-api-1.0-2.jar. Now, I have no idea how introducing :- compile("org.apache.cxf:cxf-rt-ws-security:3.1.6") has caused a conflict in stax-api-1.0-2.jar and WebLogic provided implementation. If anyone can explain this, I would really appreciate. This error is not a common and there are not obvious course of action to take first. I hope this feedback will someone some direction to take should you encounter a "LinkageError". – Pete Long Feb 04 '18 at 17:08

0 Answers0