Atomikos Forum |
|
Hi, I'm ussing AtomikosTransactionsEssentials-3.5.4, Hibernate 3.3.1.ga and Spring 2.0, Tomcat 6.0.18 and MYSQL 5.1
I saw Atomikos's documentation about how to configurate it with hibernate, spring and Tomcat. But I get the next error: org.hibernate.HibernateException: Unable to locate current JTA transaction Here is my Config: <!-------------------------------------------------> <!----------- DATA SOURCE--------------> <bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName"> <value>cemsdb</value> </property> <property name="xaDataSourceClassName"> <value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value> </property> <property name="xaProperties"> <props> <prop key="databaseName">XXXX</prop> <prop key="serverName">localhost</prop> <prop key="port">3306</prop> <prop key="user">YYYY</prop> <prop key="password">ZZZZ</prop> <prop key="url">jdbc:mysql://localhost:3306/XXXX</prop> </props> </property> <property name="minPoolSize"><value>1</value></property> </bean> <!----------------SESSION FACTORY---------------> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="/WEB-INF/hibernate.cfg.xml"/> <property name="hibernateProperties"> <props> <prop key="hibernate.connection.isolation">3</prop> <prop key="hibernate.current_session_context_class">jta</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> </props> </property> </bean> <!----------------------AtomikosTransactionManager------------> <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown" value="false" /> </bean> <!---------------AtomikosUserTransaction------------> <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300" /> </bean> <!-----------JtaTransactionManager-----------------> <bean id="JtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager" ref="AtomikosTransactionManager" /> <property name="userTransaction" ref="AtomikosUserTransaction" /> </bean> <!-------------------------------------------------> For transaction i use: sessionFactory.getCurrentSession() ANY IDEA WHAT THE PROBLEM IS? THANKS
don't do it this way.
do this: <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="atomikosDataSourceBean" /> <property name="mappingLocations"> <list> <value>classpath*:/pieces/hibernate/*.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> <prop key="hibernate.current_session_context_class">thread</prop> <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup </prop> </props> </property> </bean> <bean id="atomikosDataSourceBean" class="com.atomikos.jdbc.AtomikosDataSourceBean"> <property name="xaDataSource" ref="oracleXAdataSource" /> <property name="uniqueResourceName" value="AtomikosDataSource" /> </bean> <bean id="oracleXAdataSource" class="oracle.jdbc.xa.client.OracleXADataSource" destroy-method="close"> <property name="URL" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> |