Question

Quote from hib official docs:

Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. Given the maturity of the numerous stand-alone JTA TransactionManager implementations, most, if not all, applications should be using JTA transaction management, whether or not they are deployed into a J2EE container. Based on that, the JTA-based contextual sessions are all you need to use. end of quotation

I use tomcat6 as a servlet container, and need to integrate Hibernate 3.2 into the project.

I found a document how to configure SessionFactory lookup through JNDI, though it does not work as expected.

Quote: Hibernate works in any environment that uses JTA, in fact, we recommend to use JTA whenever possible as it is the standard Java transaction interface. End of quote.

In hibernate config I indicate current_session_context_class = jta

and now I get an error "No TransactionManagerLookup specified".

The problem is that Tomcat does not support JTA, and to get it worked, if I understand it correctly, you need to add JOTM or other library to Tomcat.

But according to quote it is recommended to use JTA.

What can you recommend in this situation?

Was it helpful?

Solution

Your choices are pretty clear:

  1. Either change to a servlet container that does support JTA
  2. Find another transaction mechanism other than JTA, such as programatically controlling transactions yourself.

OTHER TIPS

What can you recommend in this situation?

Do without JTA and use the Open Session In View pattern to handle the session.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top