2 Replies Latest reply on Sep 25, 2013 12:43 PM by mikemike

    LinkageError javax.transaction.xa.XAResource on JBoss with Hibernate, Spring and JBPM and Bitronix Transaction Manager

    mikemike Newbie

      Hi there

       

      I tried integrating JBPM5.4, with Hibernate 4.1.10 and Spring 3.1.4. I have a quite complex multi module project with a lot of dependencies that are all managed by a parent pom. I am used to using the Tomcat and the application starts fine, but now I have to switch to JBoss 7.1.1 and get a LinkageError. As I know, I have to set all JBoss provides modules with libraries in my maven pom on <scope>provided</scope>, but I don’t find a clue which ones exactly. So far I have tried eliminating everything where the interface XAResources is included (so far jta1.1 and jboss-transaction-api_1.1_spec 1.0.0.Final), but no luck. The LinkageError is still thrown. Has anybody a tip?

       

      Exception sending context initialized event to listener i
      nstance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceExceptionTranslationPostProce
      ssor' defined in class path resource [de/kkk/xxx/config/PersistenceHibernateConfig.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce
      ption: Error creating bean with name 'jbpmEMF' defined in class path resource [de/kkk/xxx/jbpm/JbpmDataSourceConfig.class]: Invocation of init method failed; nested exception is java.lang.Link
      ageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy84.getXAResource()Ljavax/transaction/xa/XAResource;" the class loader (instance of org/jboss/modu
      les/ModuleClassLoader) of the current class, $Proxy84, and the class loader (instance of <bootloader>) for interface javax/sql/XAConnection have different Class objects for the type tion/xa/XAResource
      ; used in the signature
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:734) [spring-context-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:457) [spring-context-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_06]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_06]
              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_06]
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmEMF' defined in class path resource [de/kkk/xxx/jbpm/JbpmDataSourceConfig.class]: Invocat
      ion of init method failed; nested exception is java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy84.getXAResource()Ljavax/transaction
      /xa/XAResource;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, $Proxy84, and the class loader (instance of <bootloader>) for interface javax/sql/XAConnection
      have different Class objects for the type tion/xa/XAResource; used in the signature
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:420) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139) [spring-tx-3.1.4.RELEAS
      E.jar:3.1.4.RELEASE]
              at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79) [spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70) [spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103) [spring-tx-3.1.4.RELEASE.jar:3.1.4.RELE
      ASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              ... 18 more
      Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy84.getXAResource()Ljavax/transaction/xa/XAResource;" the class loader (i
      nstance of org/jboss/modules/ModuleClassLoader) of the current class, $Proxy84, and the class loader (instance of <bootloader>) for interface javax/sql/XAConnection have different Class objects for th
      e type tion/xa/XAResource; used in the signature
              at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_06]
              at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404) [rt.jar:1.7.0_06]
              at java.lang.Class.getConstructor0(Class.java:2714) [rt.jar:1.7.0_06]
              at java.lang.Class.getConstructor(Class.java:1674) [rt.jar:1.7.0_06]
              at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:607) [rt.jar:1.7.0_06]
              at bitronix.tm.resource.jdbc.lrc.LrcXADataSource.getXAConnection(LrcXADataSource.java:106) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.jdbc.PoolingDataSource.createPooledConnection(PoolingDataSource.java:341) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.common.XAPool.createPooledObject(XAPool.java:283) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.common.XAPool.grow(XAPool.java:391) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.common.XAPool.getInPool(XAPool.java:371) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:123) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:91) [btm-2.1.3.jar:2.1.3]
              at bitronix.tm.resource.jdbc.PoolingDataSource.getConnection(PoolingDataSource.java:258) [btm-2.1.3.jar:2.1.3]
              at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70) [hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2276) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2272) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1741) [hibernate-core-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) [hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) [hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) [hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) [hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
              at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:287) [spring-orm-3.1.4.RELEASE.jar:3.1.4.RELE
      ASE]
              at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) [spring-orm-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
              ... 33 more
      
      14:24:56,183 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-11) Error listenerStart
      14:24:56,183 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-11) Context [/xxx-ui-3.0.0-SNAPSHOT] startup failed due to previous errors
      14:24:56,198 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/xxx-ui-3.0.0-SNAPSHOT]] (MSC service thread 1-11) Closing Spring root WebApplicationContext
      14:24:56,198 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/xxx-ui-3.0.0-SNAPSHOT]] (MSC service thread 1-11) Shutting down log4j
      14:24:56,198 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-11) MSC00001: Failed to start service jboss.web.deployment.default-host."/xxx-ui-3.0.0-SNAPSHOT": org.jboss.msc.service.Start
      Exception in service jboss.web.deployment.default-host."/xxx-ui-3.0.0-SNAPSHOT": JBAS018040: Failed to start context
              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_06]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_06]
              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_06]
      
      14:24:56,417 INFO  [org.jboss.as.server] (management-handler-thread - 4) JBAS015870: Deploy of deployment "xxx-ui-3.0.0-SNAPSHOT.war" was rolled back with failure message {"JBAS014671: Failed ser
      vices" => {"jboss.web.deployment.default-host.\"/xxx-ui-3.0.0-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host.\"/xxx-ui-3.0.0-SNAPSHOT\": JB
      AS018040: Failed to start context"}}
      14:24:58,492 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-11) JBAS015877: Stopped deployment xxx-ui-3.0.0-SNAPSHOT.war in 2075ms
      14:24:58,492 INFO  [org.jboss.as.controller] (management-handler-thread - 4) JBAS014774: Service status report
      JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host."/xxx-ui-3.0.0-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.web.deployment.default
      -host."/xxx-ui-3.0.0-SNAPSHOT": JBAS018040: Failed to start context
      
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 41.246s
      [INFO] Finished at: Thu Sep 19 14:24:58 CEST 2013
      [INFO] Final Memory: 45M/1038M
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:run (default-cli) on project xxx-ui: The server failed to start: Deployment failed and was rolled back. -> [Hel
      p 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
      14:24:58,601 INFO  [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
      14:24:58,601 INFO  [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
      14:24:58,601 INFO  [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager
      14:24:58,601 INFO  [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 12ms
      
      

       

      Maybe it is not important, but this output is from jboss-as-maven-plugin 7.4.Final

        • 2. Re: LinkageError javax.transaction.xa.XAResource on JBoss with Hibernate, Spring and JBPM and Bitronix Transaction Manager
          mikemike Newbie

          I solved my own problem. Before I had configured the datasource programatically and during Spring configuration I overrided the persistence.xml:

           

            @Bean
            public LocalContainerEntityManagerFactoryBean jbpmEMF() {
          
              LocalContainerEntityManagerFactoryBean jbpmEMF = new LocalContainerEntityManagerFactoryBean();
              jbpmEMF.setDataSource(poolingDataSource());
              jbpmEMF.setPersistenceUnitName("org.jbpm.persistence.jpa");
              jbpmEMF.setPersistenceXmlLocation("classpath:jbpm-persistence/persistence.xml");
              //override the connection properties
              jbpmEMF.setJpaProperties(engineProperties());
              jbpmEMF.setJpaVendorAdapter(jpaVendorAdapter());
          
              return jbpmEMF;
            }
          

           

          This was working on Tomcat very well, but caused in classloading conflicts on JBoss. All my ideas to solve it by trying a different dependency management in maven or disable modules in jboss deployment-structure.xml failed.

          In the end I stoped thinking about, why JBoss needs always an extra invitation and now I configure the datasource in JBoss and call them inside my persistence.xml with JNDI.

          Unfortunatly, my happy-go-lucky nature with deploying a single war file ends now and I am looking forward to the JBoss hell.