-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Current transaction is not in progress
PostPosted: Fri Oct 10, 2008 12:01 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
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 snippet
Code:
<!-- 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!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2008 12:06 pm 
Newbie

Joined: Fri Oct 10, 2008 11:17 am
Posts: 9
begin not get!

It's a bit lazy, but I do things like this when I'm just saving a single row:

session.beginTransaction();
session.saveOrUpdate(s);
session.getTransaction().commit();


HTH


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2008 2:42 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
I am getting exception when getting a session:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2008 2:53 pm 
Newbie

Joined: Fri Oct 10, 2008 11:17 am
Posts: 9
If you're getting that error when trying to get the session, you've got another problem. Is it a null pointer exception?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2008 3:12 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
bigcalm wrote:
If you're getting that error when trying to get the session, you've got another problem. Is it a null pointer exception?


Hi Bigcalm,

I have posted my exception above. No guess work here. Give me an answer if you have successfully configured 'jta' with Websphere AppServer6.0 or any other AppServer.

Tx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.