Announcement Announcement Module
Collapse
No announcement yet.
Spring with Atomikos Problems-XAER_DUPID: The XID identifies an existing transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring with Atomikos Problems-XAER_DUPID: The XID identifies an existing transaction

    Hello Folks
    I configured an existing solution JSF 2, JPA with SPRING with Atomikos JTA .... but this error is occurring:

    Code:
    WARNING: XA resource 'jdbc/intranet': resume for XID '696E7472616E65743230303030313030303137:696E7472616E65743231' raised -8: the supplied XID already exists in this XA resource
    javax.transaction.xa.XAException: XAER_DUPID: The XID identifies an existing transaction.
    	at net.sourceforge.jtds.jdbc.XASupport.raiseXAException(XASupport.java:677)
    	at net.sourceforge.jtds.jdbc.XASupport.xa_start(XASupport.java:191)
    	at net.sourceforge.jtds.jdbcx.JtdsXAResource.start(JtdsXAResource.java:105)
    	at com.atomikos.datasource.xa.XAResourceTransaction.resume(XAResourceTransaction.java:498)
    	at com.atomikos.datasource.xa.session.BranchEnlistedStateHandler.<init>(BranchEnlistedStateHandler.java:59)
    	at com.atomikos.datasource.xa.session.NotInBranchStateHandler.checkEnlistBeforeUse(NotInBranchStateHandler.java:65)
    	at com.atomikos.datasource.xa.session.TransactionContext.checkEnlistBeforeUse(TransactionContext.java:88)
    	at com.atomikos.datasource.xa.session.SessionHandleState.notifyBeforeUse(SessionHandleState.java:179)
    	at com.atomikos.jdbc.AtomikosConnectionProxy.enlist(AtomikosConnectionProxy.java:208)
    	at com.atomikos.jdbc.AtomikosConnectionProxy.invoke(AtomikosConnectionProxy.java:142)
    	at sun.proxy.$Proxy37.createStatement(Unknown Source)
    	at com.forj.cirrus.infra.hibernate.CirrusConnectionProvider.getConnection(CirrusConnectionProvider.java:53)
    	at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281)
    	at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
    	at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
    	at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
    	at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
    	at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    	at sun.proxy.$Proxy66.prepareStatement(Unknown Source)
    	at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
    	at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
    	at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
    	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1719)
    	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1696)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:831)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:292)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:262)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1976)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
    	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3720)
    	at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:458)
    	at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:427)
    	at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:204)
    	at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:244)
    	at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148)
    	at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1079)
    	at org.hibernate.internal.SessionImpl.access$2200(SessionImpl.java:172)
    	at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2425)
    	at org.hibernate.internal.SessionImpl.get(SessionImpl.java:979)
    	at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:271)
    	at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:151)
    	at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
    	at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:904)
    	at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:888)
    	at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:892)
    	at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:879)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:601)
    	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    	at sun.proxy.$Proxy39.merge(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:601)
    	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    	at sun.proxy.$Proxy39.merge(Unknown Source)
    When I run a bean method with only 1 insert, the error does not appear .. when I run a bean method occurs with 2 or more inserts and or updates, the error happens.
    I have several bean, calling other beans.insert () all with @ Transactional ... It seems that Atomikos is not able to properly propagate internal transactions other beans....
    This solution was already running transactions using JpaTransactionManager ... but when I configured the JtaTransactionManager stopped working ...
    My spring xml:
    Code:
    	<bean id="dataSourceBean" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jdbc/intranet" />
    		<property name="resourceRef" value="true" />
    	</bean>
    
    	<bean id="jpaDialectBean" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
    
    	<bean id="emfBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    	   <property name="persistenceUnitName" value="sistema" />
    	   <property name="dataSource" ref="dataSourceBean" />
    	   <property name="packagesToScan" value="uniprime.intranet.negocio.dominio" />
    	   <property name="jpaVendorAdapter">
    	      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    	         <property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
    	         <property name="showSql" value="true" />
    	      </bean>
    	   </property>
           <property name="jpaProperties">
           		<props>
           			<prop key="hibernate.current_session_context_class">jta</prop>
                	<prop key="hibernate.connection.provider_class">com.forj.cirrus.infra.hibernate.CirrusConnectionProvider</prop>
    				<prop key="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</prop>
                	<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
             </props>
     	   </property>
    		<property name="persistenceUnitPostProcessors">
               <list>
                   <bean class="uniprime.intranet.infra.util.TransactionTypeSelectorPersistenceUnitPostProcessor"/>
               </list>
           </property>
    	</bean>
    	<bean id="emBean" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
    		<property name="entityManagerFactory" ref="emfBean" />
    	</bean>
    	
        <bean id="userTransactionService"  class="com.atomikos.icatch.config.UserTransactionServiceImp"  
      		init-method="init" destroy-method="shutdownForce"> 
    	    <constructor-arg> 
    	        <props> 
    	            <prop key="com.atomikos.icatch.service"> 
    	              com.atomikos.icatch.standalone.UserTransactionServiceFactory 
    	            </prop> 
    	            <prop key="com.atomikos.icatch.tm_unique_name"> 
    	              intranet2
    	            </prop> 
    	        </props> 
    	    </constructor-arg> 
    	</bean> 
    
        <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
            init-method="init" destroy-method="close" depends-on="userTransactionService">
            <property name="startupTransactionService" value="false"/>
            <!-- when close is called, should we force transactions to terminate or not?  -->
            <property name="forceShutdown" value="false" />
            <property name="transactionTimeout" value="3000" />
        </bean>
    
        <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
            <property name="transactionTimeout" value="3000" />
        </bean>
        
        <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
            <property name="transactionManager" ref="atomikosTransactionManager" />
            <property name="userTransaction" ref="atomikosUserTransaction" />
        </bean>
        
        <tx:annotation-driven  transaction-manager="transactionManager"/>
    Could someone help me?
    Best Regards.

  • #2
    Don't delete .epoch files

    Hi,

    This typically happens if you delete the .epoch file - try not to do that. Otherwise, try to change the tm unique name property in jta.properties (not recommended for production use).

    HTH

    Comment

    Working...
    X