2
votes

It seems that Hibernate transactional cache mode requires the use of a JTA transaction manager. In an app server such as Glassfish, Weblogic, etc, Spring can use the JTA transaction manager. Tomcat does not have a JTA transaction manager.

Is there one that people use in this scenario? Or do people just not use transactional cache mode with Tomcat?

2

2 Answers

2
votes

It depends on you ORM implementation, for example for JPA Spring has a transaction manager for using outside Java EE containers. here's how you declare it:

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

I usually use annotations to demarcate transaction boundaries (with @Transaction), to do this you just have to add to the configuration file this other line:

<tx:annotation-driven transaction-manager="transactionManager" />

present in this XSD namespace: "http://www.springframework.org/schema/tx"

0
votes

Atomikos is one JTA transaction manager that can be bundled with your app to work in a Tomcat deployment.