I am trying to configure 'jta' as current session context with hibernate 3.2.6 and Websphere 6.0 App Server.
The following exception is thrown when I execute my code:
Code:
org.hibernate.HibernateException: Current transaction is not in progress
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:67)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
Here is my hibernate.cfg.xml snippetCode:
<!-- Enable Hibernate's automatic session context management -->
<property name="hibernate.current_session_context_class">jta</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<!-- Transaction API -->
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property >
And here is my code in DAO:
Code:
Transaction tx = null;
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
try {
tx = session.getTransaction();
//execute HQL or Criteria
tx.commit();
}catch(HibernteException ex) {
//rollback, if exception
}
What is the missing here? Is there any configuration required on WebSphere side?
I am not using EJB. So I cann't configure CMT Transaction above. I have to use bean managed transactions.
Thanks!!!