-->
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.  [ 1 post ] 
Author Message
 Post subject: Nested transactions not supported exception
PostPosted: Sat Apr 23, 2005 2:17 am 
Newbie

Joined: Sat Apr 23, 2005 1:31 am
Posts: 1
Hi, i deeply appreciate anyone who can provide any solution to this problem which i have been
trying to solve for the past 5 days but to no avail. I am facing this show-stopper in my project now. Any experts here can help me?

I am using Sun One App Server 7, Oracle 9i and Hibernate 3 for my project.

Below is my hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD //EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">jdbc/myDataSource</property>
<property name="transaction.factory.class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">framework.persistence.SunONETransactionManager</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="RoleFunctionAssignment.hbm.xml"/>
</session-factory>
</hibernate-configuration>



From above you can see that i am trying to use the SunOneTransactionManager...the code shown below was found in this forum too.

import javax.transaction.TransactionManager;
import java.util.Properties;
import com.sun.enterprise.Switch;

public class SunONETransactionManager implements TransactionManagerLookup {

public TransactionManager getTransactionManager(Properties properties) {
return Switch.getSwitch().getTransactionManager();
}

public String getUserTransactionName() {
return "UserTransaction";
}
}


I try to register the transaction as shown below in a class called HibernateUtil.java

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
try {

TransactionManager trxMgr = Switch.getSwitch().getTransactionManager();
trxMgr.begin();
javax.transaction.Transaction trx = trxMgr.getTransaction();

if (trx != null) {
trx.registerSynchronization(new HibernateSynchronisation());
}
}
catch (Exception e) {
e.printStackTrace();
} return s;
}


public class HibernateSynchronisation
implements Synchronization {

public void beforeCompletion() {

}

public void afterCompletion(int arg0) {
HibernateUtil.closeSession();
}
}

What HibernateUtil.closeSession tries to do is shown below:

session.set(null);
if (s != null && s.isOpen()) {
s.close();
}

The problem arise when whenever I try to perform more than 1 tasks in 1 action class like for example shown below,
I will get the following error.

WARNING: CORE3283: stderr: javax.transaction.NotSupportedException: Nested trans
action not supported

User user = (User) udao.create(user);
User user1 = (User)udao.findByPrimaryKey(user.getId().longValue());


If i only perform 1 task like create in 1 action class, the exception will not be thrown.

What should i do? I have tried to commit the transaction manually in the Hibernate.closeSession method.. but
it throws other exceptions.

Can any experts please help me on this issue?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.