This content has been marked as final.
Show 1 reply
-
1. Re: How to obtain the UserTransaction object in a session be
alllle Jul 3, 2006 12:29 PM (in response to alllle)Just to make this thread complete.
I've solved the problem after lots of research. The problem was actually caused by that I specified the JDBC connection information in the Hibernate configuration file directly. In other words, Hibernate uses the JDBC directly without letting the JBoss App Server to manage it. Therefore, JBoss never know there is such a JDBC data source exists and can't do commit/rollback.
To solve it, I have to create a mydb-ds.xml file and place it under the meta-inf dir of my EAR. Then in the jboss-app.xml file, I refer to it as:<jboss-app> <module> <service>meta-inf/mydb-ds.xml</service> </module> </jboss-app>
Then configure the Hibernate to use JNDI to get the reference of the data source (plenty of doc on this). Also note that the ${JBOSS_HOME}/doc/examples/jca contains lots of sample xxx-ds.xml file as template.
It seems that Hibernate document failed to mention this necessary configuration change when using JTA, and I see lots of posts with similary problem but no answers. It really should be added into the Hibernate doc.