-->
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.  [ 12 posts ] 
Author Message
 Post subject: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Wed Jul 08, 2009 12:49 pm 
Newbie

Joined: Wed Jul 08, 2009 12:22 pm
Posts: 3
Hi,

I upgraded hibernate from 3.2.5 to 3.3.2

Evironment:
-WAS 6.1.
-hibernate 3.3.2 (upgraded from 3.2.5)

cfg:
Code:
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.jndi.class">com.ibm.websphere.naming.WsnInitialContextFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>


Stack trace:

Code:
Caused by: org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]
   at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:173)
   at org.hibernate.transaction.JTATransactionFactory.isTransactionInProgress(JTATransactionFactory.java:245)
   at org.hibernate.jdbc.JDBCContext.isTransactionInProgress(JDBCContext.java:214)
   at org.hibernate.impl.SessionImpl.isTransactionInProgress(SessionImpl.java:397)
   at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:990)
   at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1718)
   at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
   at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
   ... 48 more
Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
   at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1095)
   at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:991)
   at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
   at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:384)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:204)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:144)
   at javax.naming.InitialContext.lookup(InitialContext.java:363)
   at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:163)
   ... 56 more



I found many posts in the forums regarding similar problems. Tried many suggestions, but noone can resolve the problem.
I made changes in the hibernate.cfg.xml

1. tried to replace:
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
with
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>

2. tried to comment:

<!-- <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.jndi.class">com.ibm.websphere.naming.WsnInitialContextFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
-->

Tried to mix the changes above.

Also I was debugging hibernate sources the exception occurred here:
UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( utName );
Code:
   protected UserTransaction getUserTransaction() {
      final String utName = getUserTransactionName();
      log.trace( "Attempting to locate UserTransaction via JNDI [{}]", utName );

      try {
         UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( utName );
         if ( ut == null ) {
            throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + utName +"]" );
         }

         log.trace( "Obtained UserTransaction" );

         return ut;
      }
      catch ( NamingException ne ) {
         throw new TransactionException( "Could not find UserTransaction in JNDI [" + utName + "]", ne );
      }
   }


Seeing many posts regarding the problem It seems that UserTransaction JNDI Lookup is heel of Achilles in the Hibernate.

Any idea or suggestion would be greatly appreciate. Thank you in advance.


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Thu Jul 09, 2009 9:45 am 
Newbie

Joined: Wed Jul 08, 2009 12:22 pm
Posts: 3
up


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Mon Jul 13, 2009 9:24 am 
Newbie

Joined: Wed Jul 08, 2009 12:22 pm
Posts: 3
up


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Fri Sep 18, 2009 11:56 am 
Newbie

Joined: Mon Aug 14, 2006 11:47 am
Posts: 8
has anyone a solution for this? I have exactly the same issue


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Fri Sep 18, 2009 7:25 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
comp/UserTransactio


Can you dump your namespace in WebSphere and see if this name is actually in there? It looks like a bad JNDI name has been provided.

Use the JNDI Explorer in Rational Application Developer and see if a direct lookup works. I don't think it will.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Tue Sep 22, 2009 8:02 am 
Newbie

Joined: Mon Aug 14, 2006 11:47 am
Posts: 8
the namespace dump:

56 (top)/jta javax.naming.Context
57 (top)/jta/usertransaction java.lang.Object

i tried the following:

<property name="jta.UserTransaction">jta/usertransaction</property>
<property name="jta.UserTransaction">java:comp/env/jta/usertransaction</property>
<property name="jta.UserTransaction">java:comp/jta/usertransaction</property>

but none of this properties works, the error message is always the same.

I make also a Test with:
WebSphereExtendedJTATransactionLookup lookup = new WebSphereExtendedJTATransactionLookup();
System.out.println(lookup.getUserTransactionName());

WebSphereTransactionManagerLookup lookup2 = new WebSphereTransactionManagerLookup();
System.out.println(lookup2.getUserTransactionName());

the output for both:
java:comp/UserTransaction

I don't understand why the usertransaction can't be found, it looks like my Session Bean is for the App.Server not a BMT Bean.


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Wed Sep 23, 2009 2:46 am 
Newbie

Joined: Mon Aug 14, 2006 11:47 am
Posts: 8
Addition:
The lookup on: java:comp/websphere/ExtendedJTATransaction works !

but then i run into a ClassCastException while the return is not compliant with javax.transaction.UserTransaction

any inputs ?


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Tue Jun 29, 2010 1:46 pm 
Newbie

Joined: Sat May 01, 2010 9:20 am
Posts: 6
Hello

I also have the same problem
it always throws JNDI name not found for the user transaction

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

<property name="jta.UserTransaction">
jta/usertransaction
</property>

<property name="jta.UserTransaction">
UserTransaction </property>

But none of them worked.
Did you get any solution for this


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Tue Jun 29, 2010 5:02 pm 
Newbie

Joined: Fri Jun 04, 2010 10:54 am
Posts: 10
Location: USA
This combination works for me:
Code:
            <prop key="hibernate.transaction.factory_class">
               org.hibernate.transaction.JTATransactionFactory
            </prop>
            <prop key="hibernate.transaction.manager_lookup_class">
               org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
            </prop>
            <prop key="jta.UserTransaction">java:comp/UserTransaction</prop>

Hope this helps,
-Jeff


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Tue Jun 29, 2010 5:15 pm 
Newbie

Joined: Sat May 01, 2010 9:20 am
Posts: 6
Hi Jeff,
Thanks for the reply

May I know what version of WAS are you using?


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Thu Jul 01, 2010 10:12 am 
Newbie

Joined: Fri Jun 04, 2010 10:54 am
Posts: 10
Location: USA
Sure... Environment = WAS 6.1, Hibernate 3.3.2
Any luck yet?


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.2: Could not find UserTransaction in JNDI
PostPosted: Thu Jul 01, 2010 11:09 am 
Newbie

Joined: Sat May 01, 2010 9:20 am
Posts: 6
Actually I am using WPS 6.2 which is built on WAS 6.1
And using hibernate 3.2

So, when I put 'WebSphereExtendedJTATransactionLookup' as look-up class I got

could not register synchronization with JTA TransactionManager
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:181)


so I used the WebSphereTransactionManagerLookup (even though it is for 5.x) because it did not get the above mysterious(for me) error.

Coming to the jndi name

I tried all these
<property name="jta.UserTransaction">
java:comp/usertransaction
</property>

<property name="jta.UserTransaction">
jta/usertransaction
</property>


And found none of them in the JNDI

:(
So what do you think I need to make sure of before working on this JTA transaction?


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