This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes stackoverflow JTATransactionFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "stackoverflow JTATransactionFactory" Watch "stackoverflow JTATransactionFactory" New topic

stackoverflow JTATransactionFactory

Yasir Qureshi

Joined: Apr 26, 2006
Posts: 24
I am using hibernate(3.3.1.GA) and tomcat (6.0.18), I am getting Stackoverflow exception, I have googled but could not found the fix.

This is my hibernate config file:

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/xxxx</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.connection.password">xxxx</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
<property name="hibernate.current_session_context_class">thread</property>

This is exception I am getting:

java.lang.StackOverflowError Method)
com.sun.naming.internal.VersionHelper12.getContextClassLoader(Unknown Source)
com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
javax.naming.spi.NamingManager.getObjectFactoryFromReference(Unknown Source)
javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
javax.naming.InitialContext.lookup(Unknown Source)

I found recursion in org.hibernate.transaction.JTATransactionFactory method:

protected UserTransaction getUserTransaction() {
log.trace( "Attempting to locate UserTransaction via JNDI [{}]", getUserTransactionName() );

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

log.trace( "Obtained UserTransaction" );

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

Yasir Qureshi

Joined: Apr 26, 2006
Posts: 24
No one experienced this issues ever before?
I agree. Here's the link:
subject: stackoverflow JTATransactionFactory