Link to home
Start Free TrialLog in
Avatar of pratikbm
pratikbm

asked on

JTA Transactions Spring, Hibernate in WebSphere

Hi,
I am using Spring, Hibernate and Websphere for an application. I want to use JTA Transaction.
All my transactions are rolled back, I am getting this message - WLTC0032W: One or more local transaction resources were rolled back during the cleanup of a LocalTransactionContainment. I think that Hibernate is starting its own transactions and they are rolled back by Websphere Global Transactions. How do I make Hibernate use Websphere JTA Transactions?
I tried several combinations but I think I am missing something.

Any help would be greatly appreciated.

Configuration is as follows -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="ccmDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="ccmds"/>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="ccmDataSource"/>
<property name="mappingResources">
<list>
<value>/web-inf/mapping/Sections.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<value>
org.hibernate.dialect.OracleDialect
</value>
</property>
<!--
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup">org.hibernate.transaction.WebspherExtendedJTATransactionLookup</prop>
<prop key="hibernate.transaction.flush_before_completion">true</prop>
<prop key="hibernate.transaction.auto_close_session">true</prop>
</props>
</property>
-->
</bean>

<bean id="myTxManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>


<!--
<bean id="wsJta" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" > 
<property name="userTransactionName"><null /></property>
<property name="transactionManager" ref="wsJta" />
</bean>
-->

<bean id="templateDesignDAO" class="com.ubs.ccm.dao.TemplateDesignDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>


<bean id="templateDesignService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>
com.ubs.ccm.dao.TemplateDesignDAO
</value>
</list>
</property>
<property name="target">
<ref bean="templateDesignDAO"/>
</property>
<property name="transactionManager">
<ref bean="myTxManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="addSection">
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
</prop>
</props>
</property>
</bean>


</beans>



Avatar of Gibu George
Gibu George
Flag of India image

Hello pratikbm,

Try this
<property name="org.hibernate.transaction.JTATransactionFactory">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
instead of
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup">org.hibernate.transaction.WebspherExtendedJTATransactionLookup</prop>

Regards,

gibu_george
Avatar of pratikbm
pratikbm

ASKER

I had tried this approach and it didn't work.
The problem is with how websphere server handles transactions. The problem was solved after making changes to web.xml. In webspher extensions, setting "Unresolved Action" to Commit under Local Transaction solved this problem.

Thanks,
Hemant
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial