File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Transaction Rollback Fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transaction Rollback Fails" Watch "Transaction Rollback Fails" New topic
Author

Transaction Rollback Fails

blr sam
Greenhorn

Joined: Jan 15, 2002
Posts: 7
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

Joined: Dec 08, 2000
Posts: 17
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

Joined: Aug 04, 2001
Posts: 51
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.


Thanks & Regards<br />glkishore
Subhash Nambiar
Greenhorn

Joined: Jan 11, 2002
Posts: 26
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

Joined: Jan 11, 2002
Posts: 26
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
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.
 
 
subject: Transaction Rollback Fails