views:

456

answers:

2

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?

A: 

What can you recommend in this situation?

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

Pascal Thivent
Care to explain the downvote?
Pascal Thivent
@Pascal Thivent Don't know who voted down your question, but I undid it anyway. You know, Spring documentation made me feel that Spring is the right decision for the problem. Do you have any good tutorial link how to setup Spring to do the thing I need (configure SessionFactory etc) ?
EugeneP
@EugeneP http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html#orm-hibernate
matt b
@EugeneP Thanks (if something is wrong with my answer, I like to get at least the opportunity to fix it). Regarding Spring + Hibernate, the link posted by @matt is the right place to look at.
Pascal Thivent
+1  A: 

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.
matt b