[jboss-user] [Management, JMX/JBoss] - tranasction context propagation..ejb 3

david81 do-not-reply at jboss.com
Wed Nov 21 09:56:40 EST 2007


Hi ,

I am stuck in an issue and need your help on it.

I have an ejb (Bean1) where in a transaction is started.
>From this ejb (Bean1) if I call another ejb(Bean2), and anything wrong happens in Bean2, whole of the transaction is rolled back. 
This is controlled by the Jboss.

My query is..
If from Bean1, I make a call to some utility class which makes entires into DB and  if an error happens in Bean1 , after utility class commits the DB changes. How can I rollback the changes made in utility class.

In short, how is the transaction in EJB3 propagated to utility class?

I am using hibernate in utility class and the application server used is JBoss4.

    I  set hibernate.transaction.manager_lookup_class
    and  set hibernate.transaction.factory_class to org.hibernate.transaction.JTATransactionFactory

My code in utility class..

UserTransaction tx = (UserTransaction)new InitialContext()
                            .lookup("java:comp/UserTransaction");


try {
    tx.begin();

    // Do some work
    saved object using hibernate session

    tx.commit();
}
catch (RuntimeException e) {
    tx.rollback();
    throw e; // or display error message
}



I get an error which says the transaction is not active.


Can you please tell what could be the problem?

Thanks,

David





View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106775#4106775

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106775



More information about the jboss-user mailing list