• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding transactions between ejbs

 
venkata kri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Ravikumar
 
Vichan Chutitaporn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the transaction attribute of method in EJB B is "requiredNew". Change the txn attribute to "require"
 
venkata kri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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
krisha
 
Amit M Tank
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic