WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

java.lang.LinkageError: loading constraint violation after migrating applications from WebSphere v7 to WebSphere Application Server v8.5.5.x

  • 1.  java.lang.LinkageError: loading constraint violation after migrating applications from WebSphere v7 to WebSphere Application Server v8.5.5.x

    Posted Wed December 11, 2024 03:06 PM

    Problem:
    We recently migrated our applications from WebSphere Application Server v7.x to WebSphere Application Server V8.5.5.25. After the migration
    the application fails to start and throws the following error:

    o
    rg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SOAPGateway': Invocation of init method failed; nested exception is java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader@bcdb63c0" previously initiated loading for a different type with name "javax/xml/bind/JAXBContext" defined by loader "com/ibm/oti/vm/BootstrapClassLoader@fef56328"
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636) ~[org.apache.servicemix.bundles.spring-beans-3.2.13.RELEASE_1.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934) ~[org.apache.servicemix.bundles.spring-context-3.2.13.RELEASE_1.jar:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[org.apache.servicemix.bundles.spring-context-3.2.13.RELEASE_1.jar:na]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410) [org.apache.servicemix.bundles.spring-web-3.2.13.RELEASE_1.jar:na]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [org.apache.servicemix.bundles.spring-web-3.2.13.RELEASE_1.jar:na]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [org.apache.servicemix.bundles.spring-web-3.2.13.RELEASE_1.jar:na]
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1747) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:415) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:171) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719) [com.ibm.ws.webcontainer.jar:na]
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1211) [com.ibm.ws.runtime.jar:na]
    ......
    Caused by: java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader@bcdb63c0" previously initiated loading for a different type with name "javax/xml/bind/JAXBContext" defined by loader "com/ibm/oti/vm/BootstrapClassLoader@fef56328"
    at java.lang.ClassLoader.defineClassImpl(Native Method) ~[na:2.9 (09-08-2023)]
    at java.lang.ClassLoader.defineClassInternal(ClassLoader.java:397) ~[na:2.9 (09-08-2023)]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:358) ~[na:2.9 (09-08-2023)]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154) ~[na:1.8.0]
    at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:877) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf252402.01]]
    at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:785) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf252402.01]]
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:626) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf252402.01]]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:876) ~[na:2.9 (09-08-2023)]
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345) ~[cxf-api-2.7.16.jar:2.7.16]
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:343) ~[cxf-api-2.7.16.jar:2.7.16]
    at java.security.AccessController.doPrivileged(AccessController.java:746) ~[na:1.8.0]
    --------------



    ------------------------------
    Sai Vamsi Gude
    ------------------------------


  • 2.  RE: java.lang.LinkageError: loading constraint violation after migrating applications from WebSphere v7 to WebSphere Application Server v8.5.5.x
    Best Answer

    Posted Wed December 11, 2024 03:07 PM
    Edited by Sai Vamsi Gude Wed December 11, 2024 03:09 PM


    The java.lang.LinkageError indicates that the application classloader is attempting to load another version of the " javax.xml.bind.JAXBContext" which was already loaded by the JVM.  You might be packaging jaxb api jar(containing this javax.xml.bind.JAXBContext class) with your application.

    Please refer to the following technote where we clearly stated the following:

    https://www.ibm.com/support/pages/best-practice-using-common-application-files

    Note: If a .jar file contains a Java Extension class (javax.*.class) file which is also provided by WebSphere, then it must not be included in your Shared Library or application, or else a ClassCastException or similar error will occur. If the javax.*.class is NOT provided by WebSphere Application Server, then feel free to use that .jar in your application or Shared Library.

    The simplest solution is to remove the JAXB API jar from the application. WAS already contains JAXB 2.2, so it's unlikely that the application would specifically require its own copy of JAXB. Alternately,  you could switch the class loader delegation of the web module from parent-last to parent-first, although if you are using parent-last to override some WAS implementation, that would no longer work.



    ------------------------------
    GEETA NADELLA
    ------------------------------