7 Replies Latest reply on Mar 25, 2013 6:59 PM by Scott Marlow

    Hibernate4 <-> Jboss7 Problem (java:jboss/UserTransaction)

    Tom Smith Newbie

      While porting my application from Jboss6 to Jboss7 there is another problem raised raised. I found some entries in google but none of them were actually in the situation of jboss7/hibernate4. Mentioned solutions do not work.

       

      org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:comp/UserTransaction]

       

      I know that java:comp/UserTransaction is only visible for container created threads of jee, so not for my quartz threads.

       

      The right thing for me seems to be java:jboss/UserTransaction

       

       

      none of the mentioned config options worked for me. There is always java:comp/UserTransaction looked up from hibernate which fails in quartz threads.

       

      I tried:

       

              <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

              <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

              <property name="jta.UserTransaction" value="java:jboss/UserTransaction"/>

       

      jta.UserTransaction property is listed in hibernate docs.

       

       

      I replaced the last one already with following possiblities, of which none had an effect:

       

      <property name="hibernate.jta.UserTransaction" value="java:jboss/UserTransaction"/>

      <property name="jta.UserTransaction" value="java:jboss/UserTransaction"/>

      <property name="jta.UserTransactionName" value="java:jboss/UserTransaction"/>

      <property name="hibernate.jta.UserTransactionName" value="java:jboss/UserTransaction"/>

       

       

      jboss says at startup:

       

      23:31:19,113 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-3) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory

       

      transactions work in the normal application!

       

       

      Code that raises the exception is (the last line actually leads to exception):

       

      sqlSession = HibernateUtil.getSessionFactory().openSession();

      tx = sqlSession.beginTransaction();

       

       

       

       

      Thanks again!