-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with Generic Dao / JBoss / JTA
PostPosted: Wed Apr 04, 2007 8:10 am 
Newbie

Joined: Thu Jan 25, 2007 11:27 am
Posts: 4
Hello

I am using the Generic DAO approach as described here:
http://www.hibernate.org/328.html

I am using JBoss and JTA with Beans Managed Transactions.

I have set the followong properties:

hibernate.current_session_context_class=jta

hibernate.transaction.manager_lookup_class= org.hibernate.transaction.JBossTransactionManagerLookup

hibernate.transaction.factory_class= org.hibernate.transaction.JTATransactionFactory


in my Session Bean I use this code:

Code:
         * saves a given bird to the database
    * @ejb.interface-method view-type="remote"
    *
    */
   public void saveBirdType(BirdType type) {
      UserTransaction utx = null;
      try {
         utx = (UserTransaction) new InitialContext()
               .lookup("java:comp/UserTransaction");
         utx.begin();
         DaoFactory factory = new HibernateDaoFactory();
         BirdTypeDao dao = factory.getBirdTypeDao();
         dao.save(type);
         utx.commit();
      } catch (Exception ex) {
         try {
            utx.rollback();
         } catch (Exception e) {
            log.error("can not rollback transaction" + e.getMessage(), ex);
         }

      }
   }




I use the HibernateUtil class that comes with the
caveatemptor-native-061211
source code.


I use Hibernate 3.1 RC 1 (can not upgrade right now), JBoss 4.0.3, EJB 2.1 and Java 5.

as a database system I use Oracle 10g.


I get this error:

Caused by: org.hibernate.HibernateException: Unable to locate current JTA transaction
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:604)




any idea what's wrong here ?

Claus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 2:44 am 
Newbie

Joined: Thu Jan 25, 2007 11:27 am
Posts: 4
found the problem. I had a read only SELECT query in another method
which was not wrapped in a transaction.

Claus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.