简体   繁体   中英

LinkageError - loading contraint violation

I am facing LinkageError in websphere application server(8.5.5.14). A similar issue found here LinkageError

Caused by: java.lang.LinkageError: loading constraint violation when resolving method "javax/xml/soap/SOAPElement.getElementQName()Ljavax/xml/namespace/QName;": loader "com/ibm/ws/classloader/CompoundClassLoader@19d4f90e" of class "org/springframework/ws/soap/saaj/SaajSoapElement" and loader "com/ibm/oti/vm/BootstrapClassLoader@ca532309" of class "javax/xml/soap/SOAPElement" have different types for the method signature

The cause of the issue is the inclusion of an XML API jar containing javax/xml/namespace/QName in your application, and that application being configured to use parent-last class loading. When that happens, you get the following linkage pattern:

  1. Application class references javax/xml/soap/SOAPElement - this class is loaded from the JDK
  2. SOAPElement references javax/xml/namespace/QName - it loads that using its own class loader, so it's also found in the JDK
  3. Application class references org/springframework/ws/soap/saaj/SaajSoapElement - this class is loaded from the application
  4. SaajSoapElement references both SOAPElement and QName - SOAPElement is loaded from the JDK (as before), but QName is loaded from the application, because parent-last class loader delegation requires that the class loader search locally before delegating to parents
  5. SaajSoapElement now can "see" both copies of QName, and Java throws a LinkageError, because that violates loading constraints

You can solve this by removing the XML jar containing the QName class from your application (the API is included in the server's JDK), by adding the SOAP API to the application (so the application "sees" both classes from the same location), or by switching your class loading to parent-first. Parent-last class loading is generally vulnerable to issues like this, because it allows for more duplicate loading between class loaders than is typically possible under default settings. If you don't have a very explicit need for your own XML API version (XML APIs have been included in Java SE for a very long time), I'd strongly recommend either removing the jar or switching to parent-first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM