Atomikos Forum |
|
Our application interacts with three diffenret databases(Oracle, MYSQL, Informix) and presently it is uing Websphere transaction manager. I am trying to replace it with Atomikos(3.5.9). I was able to successfully integrate Atomikos with Spring(2.5) and Hibernate(3.3.2.GA) but id does not rollback a transaction. To narrow down the issue, I have tried configuring only one datasource(Oracle 10g) but still not able to rollback a transaction. Please see the below configuration files and let me know if I am doing any mistake. I have already spent two weeks working on this but no luck. If integration with Atomikos gets successfull in the present Websphere environment then we would move to open-source container like Tomcat.
============================================================== Hibernate-config file: <beans> <bean id="datasource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName"><value>XADBMS</value></property> <property name="xaDataSourceClassName"><value>oracle.jdbc.xa.client.OracleXADataSource</value></property> <property name="xaProperties"> <props> <prop key="user">dblogin</prop> <prop key="password">dbpasswd</prop> <prop key="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL = TCP)(HOST = abc.xyz.net)(PORT = 1140))(CONNECT_DATA=(SERVICE_NAME = qwe.xyz.net)))</prop> </props> </property> <property name="minPoolSize"> <value>1</value> </property> <property name="maxPoolSize"> <value>3</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="mappingResources"> <list> <value>/xyz/resources/rdb/appRdb/hibernate_visitor_badge_owner_mapping.xml</value> </list> </property> <property name="dataSource"><ref bean="datasource"/></property> <!-- configure hibernate to use Atomikos TransactionsEssentials --> <property name="hibernateProperties"> <props> <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop> <!-- <prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory</prop> --> <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop> <prop key="hibernate.connection.isolation">3</prop> <prop key="hibernate.current_session_context_class">jta</prop> <prop key="hibernate.connection.autocommit">false</prop> <prop key="hibernate.connection.release_mode">after_transaction</prop> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.query.substitutions">true=1, false=0</prop> <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop> <prop key="hibernate.jdbc.batch_size">0</prop> <prop key="hibernate.jdbc.use_streams_for_binary">true</prop> <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop> <prop key="hibernate.query.imports">xyz.domainobject</prop> <prop key="hibernate.jdbc.batch_versioned_data">true</prop> <prop key="hibernate.jdbc.use_scrollable_resultset">true</prop> </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"><ref bean="sessionFactory"/></property> </bean> <bean id="visitorOwnerDAOTarget" class="xyz.dao.rdb.hibernate.VBOwnerDAOHibernate"> <property name="hibernateTemplate"> <ref local="hibernateTemplate"/> </property> </bean> </beans> ================================================================ Spring-ApplicationContext xml file: <beans > <!-- ======================== ATOMIKOS TRANSACTION MANAGER ======================== --> <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown" value="false" /> </bean> <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300" /> </bean> <bean id="JtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager" ref="AtomikosTransactionManager" /> <property name="userTransaction" ref="AtomikosUserTransaction" /> </bean> <bean id="transactionXAServiceTarget" class="xyz.service.impl.TransactionXAServiceImpl"> <property name="visitorOwnerDAOTarget"> <ref bean="visitorOwnerDAOTarget"/> </property> </bean> <!-- Configure Spring to insert JTA transaction logic for all methods --> <bean id="transactionXAService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref bean="JtaTransactionManager"/></property> <property name="target"><ref bean="transactionXAServiceTarget" /></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED, -NullPointerException</prop> </props> </property> </bean> </beans> ================================================================ Code snippet from xyz.service.impl.TransactionXAServiceImpl: handleXATransaction()throws NullPointerException(){ visitorOwnerDAOTarget.store(visitorOwnerDO); if(1 == 1){ throw new NullPointerException("Testing roll back"); } } ============================================================= Code snippet from xyz.dao.rdb.hibernate.VBOwnerDAOHibernate store(visOnerDO){ Long generatedId =(Long)getHibernateTemplate().save(visOnerDO); } ========================================================== After looking at the Spring example in the Atomikos download, I tried to do a sample integration of two of our application datasources with Spring and JDBC and was able to rollback the transaction successfully in differnet scenarios. But with Hibernate and Spring I am not able to rollback the transaction at all. Please guide me.
Thanks for the quick response.
I have tried both <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop> and <prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory</prop> Either one, it doesn't make any difference.Now, I tried it out again. Please see the below information if it helps: When I ran the simple application outside the container, somewhere in the logs it says"[main] DEBUG org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371) - Creating new transaction with name........" and "Creating composite transaction: com.atomikos.spring.jdbc.tm0000100009.....". But, I don't find anywhere in my application logs about creating a transaction...Please let me know if you need any other information to solve my problem...
Hi,
I guess the easy answer did not work then ;-) So the real solution will most likely require analysis on log files to figure out the specifics. Would you have access to a budget for 'developer access' (see http://www.atomikos.com/Main/AtomikosQuote)? If so, we can arrange for a one-on-one remote session to sort this out... Thanks
Hi Guy,
While I was waiting for your response, and after reading the thread default82df.html?community.6.1107.1 I tried to test the service from a stand alone java main class(directly calling the applicationContext.xml file) rather than the using JUnit and it wokrs :). But still confused what could have been the problem. After going through the logs I found the below line missing from the log that was generated while testing with JUnit. "[main] INFO atomikos - createCompositeTransaction ( 300000 ): created new ROOT transaction with id com.atomikos.spring.jdbc.tm0000100017" I am guessing the reason for my problem is JUnit but not WebSphere server. Please let me know if there is any specific configuration that needs to be done while using Atomikos in WebSphere(RAD). After reading through your documentation I have seen some configuration steps specific to Tomcat but found nothing for WebSphere. Do you think there is any known issue using Atomikos and Spring/Hibernate with JUnit? |