I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I\'d like to use JBoss\' own TransactionManager, an
Just adding my experience here so I don't have to re-suffer the experience again.
As bmatthews68, Chochos and these posters have said, use
in your Spring bean file; it definitely provides the appropriate level of abstraction and there's no need to do anything extra on the Spring side.
As for Tomcat, I declared
in the default/shared conf/context.xml
file, which binds to java:comp/UserTransaction
. As this is one of the places searched for by Spring, you shouldn't need to do anything else.
One gotcha though: if like me you use Maven, make sure you exclude any dependencies on the javax.transaction:jta
jar or set the scope to provided
. Otherwise you will experience classloader issues.