[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JTA Transactions Spring, Hibernate in WebSphere

Posted on 2007-09-28
4
Medium Priority
?
10,212 Views
Last Modified: 2013-12-11
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>



0
Comment
Question by:pratikbm
3 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 19990481
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
0
 

Author Comment

by:pratikbm
ID: 20007312
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
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20439005
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question