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.