PDA

View Full Version : WebSphere 5.0 and WebSphereTransactionManagerFactoryBean


markash
Aug 19th, 2004, 08:47 AM
Good Day,

javascript:emoticon(':?')
Confused
I am trying to get the Connection from a DataSoure that is managed by WebSphere 5.1 Application Server. I was able to lookup the DataSource using JNDI but when I try to use the WebSphereTransactionManagerFactoryBean to get the TransactionManager I get a classcast error from the BeansWrapper.

It looks like the WebSphereTransactionManagerFactoryBean is not the correct type of object to reference in bean customer
but I cannot find a way to call the getObject method that returns the TransactionManager in the customer bean.

javascript:emoticon(':wink:')
Wink

Basically, if somebody could show how to use this class in the applicationContext.xml to get a WebSphere Transaction Manager that would be great.



<!-- WebSphere Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereTrans actionManagerFactoryBean" />
-->

<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

<!-- Transactional proxy for the Petclinic primary business object -->
<bean id="customer" class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="target"><ref local="customerTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="store*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
:?

2devnull
Aug 19th, 2004, 10:15 AM
I have to do the same thing today. I will let you know how it goes. Maybe I will run into the same problem :x

Colin Sampaleanu
Aug 19th, 2004, 10:26 AM
You should be using Spring's JTATransactionManager. There's examples for that in some of the samples.

JTATransactionManager normally works with the standard JTA UserTransaction object, but it has more advanced functionality (as per the JavaDocs) when it can get it's hands on the appserver's JTA TransactionManager instance. THIS is what you would use WebSphereTransactionManagerFactoryBean for. The latter looks up the JTA TransactionManager in a WebSphere environment. You feed an instance of the latter into the 'TransactionManager' property of Spring's JTATransactionManager, and you are good to go.

Regards,

markash
Aug 19th, 2004, 12:06 PM
Thanks for the reply. :P

I tried the JTATransactionManager first but there was a problem when it was trying to interact with the connection (reading data) and I therefore thought that the WebSphere specfic one would do the trick.

markash
Sep 30th, 2004, 12:04 AM
Good Day,

The problem is 10 to 1 a problem with the Microsoft JDBC driver that comes with WebSphere. Hibernate mentions that it does not support this driver and as an alternative have found the jTDS driver. It solved two other problems when it came to the MS JDBC driver so it should fix this one as well.


jTDS Home page (http://jtds.sourceforge.net/)

jochuan
Dec 8th, 2007, 04:47 AM
Hi..from JTA newbie

I think i got the part about configuring JTA in WebSphere (mine is 5.1) is to use the JTATransactionManager with WebSphereTransactionManagerFactoryBean. The part that i don't get is the datasource wire-in. In the Spring reference,I quote...the following...

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/jpetstore"/>
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransaction Manager" />

If we use JTA in a J2EE container, as in the 'dataAccessContext-jta.xml' file from the same sample application, we use a container DataSource, obtained via JNDI, in conjunction with Spring's JtaTransactionManager. The JtaTransactionManager doesn't need to know about the DataSource, or any other specific resources, as it will use the container's global transaction management infrastructure.

It lookis to me like the two sentences are contradicting each other. First I need to wire in the JNDI look-up but then it said JtaTransactionManager does not need to know any datasource. How does it know which credentials/connnection pool to use?

Heavily confused individual