wood burning stoves
The moose likes EJB and other Java EE Technologies and the fly likes regarding transactions between ejbs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "regarding transactions between ejbs" Watch "regarding transactions between ejbs" New topic

regarding transactions between ejbs

venkata kri

Joined: Jun 09, 2008
Posts: 4
Hi Friends,

I got one problem in my application, that is the transaction is not maintaining between two EJB's.

Example : Take two EJB's A and B.
In A ejb i started one transaction and this ejb is calling another ejb B. In this B ejb, the new transaction is starting and commiting and then coming back to the A and remaining code is executing.

But the problem is, suppose if i get any exception in the end of the A ejb(that is B ejb execution completed) then
in the Database operations in the ejb B are not rolledback. only the database operations in A are rollback.

So how can i maintain the trasaction between the two EJB's (A and B).
Is it possible to maintain the transaction between two EJB's ???
Please give me solution for this

Thanks and Regards,

Vichan Chutitaporn

Joined: Apr 18, 2008
Posts: 3
I guess the transaction attribute of method in EJB B is "requiredNew". Change the txn attribute to "require"
venkata kri

Joined: Jun 09, 2008
Posts: 4

I am using BeanManagedTransactions.
Is it possible to maintain the transaction state between ejb's?

please respond me as soon as possible

Thanks in advance
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
If you use the "Required" transaction attribute then the same transaction context will propogate from EJB A to EJB B. I am not sure about BMT, but I guess you have to get the user transaction in EJB A and do an explicit rollback in case of an Exception.

Amit Tank
Linked In
I agree. Here's the link: http://aspose.com/file-tools
subject: regarding transactions between ejbs
It's not a secret anymore!