We are trying to upgrade from Spring 1.2.8 to Spring 3.0 However when we are trying to configure txManager for Websphere I always get a class cast exception. We tried based on the example provided by IBM which doesn't work. I am using WAS 7.0 and Spring.3.0.5 and hibernate.3.6.jars... Here is the Spring config:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="ewpDataSource" />
<property name="mappingResources">
<list>
<value>com/fme/example/model/Person.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.default_schema">ORIG</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</prop>
<prop key="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
</prop>
</props>
</property>
</bean>
<!-- Our Data source --->
<bean id="ewpDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/TOI_ORIG" />
</bean>
<!--- Get the Web sphere Specific TX manager -->
<bean id="transactionManager"
class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>
</beans>
I read this article and tried exactly as specified. http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html And also tried http://robertmaldon.blogspot.com/2006/09/using-websphere-transaction-manager.html
But we are getting this Exception.
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.transaction.jta.WebSphereUowTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
I see that the class org.springframework.transaction.jta.WebSphereUowTransactionManager provided for Websphere doesn't implement javax.transaction.TransactionManager any where in the hierarchy.
Any idea?
I got it working. In addition to the above hibernate settings here is what I did.
The object of type WebSphereUowTransactionManager is not an instance of
javax.transaction.TransactionManager
but there is superclass method inside WebSphereUowTransactionManager
called getTransactionManager()
this returns object of type javax.transaction.TransactionManager
<bean id="wasUOWTxnManagerObj"
class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>
<!--
Now call get getTransactionManager on WebSphereUowTransactionManager
object.
-->
<bean id="tranSactionManager"
class="javax.transaction.TransactionManager"
factory-bean="wasUOWTxnManagerObj"
factory-method="getTransactionManager">
</bean>
With this change now you can use WebSphereUowTransactionManager. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With