Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Rollback Fails

 
blr sam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am calling the create() of 2 CMP beans one after the other in a session bean method. In the 2nd CMP create() method i am throwing an exception. This exception is caught in the session bean method where context.setRollBack() is called. Both the CMP beans have transaction set to SUPPORT and the session bean is set to REQUIRED.
I assumed that the 1st create() method would rollback too but i find in the database that the record exists. The 2nd create() method has failed.
This is what i tried:
a. Transaction attributes of all 3 beans.
b. Both user managed and container managed transaction.
I must be missing something.
Thx in advance.
 
Rasmeet Devji
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
You could possibly get your piece of code posted here, that would give a clear picture of what you are trying to do.
One reason could well be the usage of the type of datasource you use. TX DataSource to be used for transactions. Give it a shot and do give your feedback.
Regards.
 
Lakshmi Kishore
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
try to starts your own transaction by using "UserTransaction", put the code between the ut.begin() and end with ut.commit() or rollback(), this will solve your problem.
 
Subhash Nambiar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the cmp transaction attribute as "Required" as both Required and Supports is similar in nature with one exception and that is in case "required" a new transaction is started if one is not running already but support will sometimes not run within a transaction .
 
Subhash Nambiar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the cmp transaction attribute as "Required" as both Required and Supports is similar in nature with one exception and that is in case "required" a new transaction is started if one is not running already but support will sometimes not run within a transaction .

Subhash
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What application server (and version) are you using and which version of the EJB spec are you writing to? It really does make a difference...
Kyle
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earlier implementations of EJB were "loose" on the inclusion of home methods (like create) in a transaction (because the spec was vague). I forget when it changed (1.1 or 2.0), but with the current spec you can specify Home and/or Remote interface in the method element of the deployment descriptor where you are describing the transaction attributes.
Make sure the Home create method is included in your transaction settings.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic