Atomikos Forum |
|
Hi I am trying configured Atomikos in my project to achieve the global transaction. We are using Spring 3.0/Hibernate 3.0 with WAS as application server. The spring configuration file looks as follows:
<bean id="AomikosDataSourceBeanCU" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close" lazy-init="false" > <property name="uniqueResourceName" value="jtaDataSource" /> <property name="xaDataSourceClassName"><value>com.ibm.db2.jcc.DB2XADataSource</value></property> <property name="xaDataSource" ref="JTAXADataSourceCU" /> <property name="maxPoolSize" value="5" /> <property name="poolSize" value="3"/> <property name="borrowConnectionTimeout" value="50" /><!-- default is 30 sec --> <property name="testQuery" value="select 1 from dual" /> </bean> <bean id="JTAXADataSourceCU" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton"> <property name="jndiName"> <value>jdbc/cuds</value> </property> <property name="expectedType"><value>javax.sql.XADataSource</value></property> <property name="resourceRef" value="true"/> </bean> <bean id="AomikosDataSourceBeanGodb" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close" lazy-init="false" > <property name="uniqueResourceName" value="jtaDataSource" /> <property name="xaDataSourceClassName"><value>com.ibm.db2.jcc.DB2XADataSource</value></property> <property name="xaDataSource" ref="JTAXADataSourceGodb" /> <property name="maxPoolSize" value="5" /> <property name="poolSize" value="3"/> <property name="borrowConnectionTimeout" value="50" /><!-- default is 30 sec --> <property name="testQuery" value="select 1 from dual" /> </bean> <bean id="JTAXADataSourceGodb" class="org.springframework.jndi.JndiObjectFactoryBean" scope="singleton"> <property name="jndiName"><value>jdbc/pushpullds</value></property> <property name="expectedType"><value>javax.sql.XADataSource</value></property> <property name="resourceRef" value="true"/> </bean> <bean id="sessionFactoryCu" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="AomikosDataSourceBeanCU"/> <property name="packagesToScan" value="com.hll.centralunify.spring.entity.cu"/> <property name="hibernateProperties" ref="hibernateConfiguration"/> </bean> <bean id="sessionFactoryGodb" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="AomikosDataSourceBeanGodb"/> <property name="packagesToScan" value="com.hll.centralunify.spring.entity.godb"/> <property name="hibernateProperties" ref="hibernateConfiguration"/> </bean> <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <!-- when close is called, should we force transactions to terminate or not? --> <property name="forceShutdown" value="false" /> </bean> <!--Also use Atomikos UserTransactionImp, needed to configure Spring --> <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300" /> </bean> <!--Configure the Spring framework to use JTA transactions from Atomikos --> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager" ref="AtomikosTransactionManager" /> <property name="userTransaction" ref="AtomikosUserTransaction" /> </bean> But, while executing the below set of codes, I am getting "An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction." error if any of the database operation fails. @Override @Transactional public boolean saveTsoEmployeeAndIqScopeSync(final TSOEmployee e, final IqScopeSync iq) throws CUException { TransactionTemplate tx = new TransactionTemplate(transactionManager); tx.execute(new TransactionCallback<Void>() { public Void doInTransaction(TransactionStatus ts) { try { iQPADForumDao.saveTsoEmployee(e); iqScopeSyncDao.saveIqScopeSync(iq); } catch (CUException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); return true; } Can any one please help me to figure out where is the issue. Thanks. |