wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transacton CMT  : Rollback throws exception but does not actually rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Transacton CMT  : Rollback throws exception but does not actually rollback " Watch "Transacton CMT  : Rollback throws exception but does not actually rollback " New topic
Author

Transacton CMT : Rollback throws exception but does not actually rollback

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Transacton CMT : Rollback throws exception but does not actually rollback things.


Result on server:
11:46:32,765 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 26s:890ms
11:49:29,921 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
11:49:29,937 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 29s:672ms

11:49:34,703 INFO [STDOUT] Before adding: Number of bids:0
11:49:34,703 INFO [STDOUT] After adding, Number of bids:1
11:49:34,703 INFO [STDOUT] Exception in getBids:bids.getSize():0
11:46:38,187 INFO [STDOUT] Exception in getBids rg.jboss.util.NestedSQLException: Transaction TransactionImple < ac, BasicAction:
7f000001:434:4959bcac:39 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK; - nested throwable:
(javax.transaction.RollbackException: Transaction TransactionImple < ac, BasicAction: 7f000001:434:4959bcac:39 status:
ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK)
11:49:34,703 INFO [STDOUT] After rollback, Number of bids:0

11:49:42,625 INFO [STDOUT] Before adding: Number of bids:1
11:49:42,625 INFO [STDOUT] After adding, Number of bids:2
11:49:42,625 INFO [STDOUT] Exception in getBids:bids.getSize():0
11:46:38,187 INFO [STDOUT] Exception in getBids rg.jboss.util.NestedSQLException: Transaction TransactionImple < ac, BasicAction:
7f000001:434:4959bcac:39 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK; - nested throwable:
(javax.transaction.RollbackException: Transaction TransactionImple < ac, BasicAction: 7f000001:434:4959bcac:39 status:
ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK)
11:49:42,625 INFO [STDOUT] After rollback, Number of bids:0

11:49:46,031 INFO [STDOUT] Before adding: Number of bids:2
11:49:46,031 INFO [STDOUT] After adding, Number of bids:3
11:49:46,031 INFO [STDOUT] Exception in getBids:bids.getSize():0
11:46:38,187 INFO [STDOUT] Exception in getBids rg.jboss.util.NestedSQLException: Transaction TransactionImple < ac, BasicAction:
7f000001:434:4959bcac:39 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK; - nested throwable:
(javax.transaction.RollbackException: Transaction TransactionImple < ac, BasicAction: 7f000001:434:4959bcac:39 status:
ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK)
11:49:46,031 INFO [STDOUT] After rollback, Number of bids:0


Result on client :
[java] javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.inte
[java] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)
[java] at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
[java] at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
[java] at org.jboss.tm.usertx.server.UserTransactionSessionImpl.commit(UserTransactionSessionImpl.java:172)


The above exception was thrown each time startThings() was invoked on the client side.

The things am complaing about are
a) The result i was expecting to see on server side after invoking startThing() each time was
11:28:14,375 INFO [STDOUT] Before adding: Number of bids:0
11:28:14,375 INFO [STDOUT] After adding, Number of bids:1
11:30:03,250 INFO [STDOUT] After rollback, Number of bids:1

Once i add the bid on the item and later i invoke setRollbackOnly().setRollbackOnly() sets only a flag
and does not actually rollback things. Once startThings() completes there should have been an exception
thrown at the server side. I don't know what should have been the name of this exception or wheather it
should have been logged on server side or not.But whatever it would have been it should have happened
at the end of the business method startThings(). However here there is some exception that is
thrown when i invoke getBids().

Does this mean, if a transaction has been marked for rollback and if any bean method is invoked after that
which attempts to access database, will simply throw and exception without actually accessing database?
And as a result the arrayList defined in getBids() simply returns with size 0 which is what is shown
in logs as 11:49:46,031 INFO [STDOUT] After rollback, Number of bids:0

b) This is most strangest thing. The rollback never happend with the database. A third invocation of startThing() gave 11:49:46,031 INFO [STDOUT] Before adding: Number of bids:2 . this confirms that even when the transaction was marked for rollback the data base rollback never happened.
I confirmed this behavior when i invoked getBids() from client side and it returned me a list of 4 records.

Application Server: JBOSS 4.2.3 GA. I seriously having so many issues with hands on experience with EJB.


SCJP, SCWCD, SCBCD
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9955
    
163

Which database server are you using? As far as i know, if you are using MySQL then it comes in 2 flavours - one which supports transactions and one which does not.


[My Blog] [JavaRanch Journal]
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Example is an extension of examples in EJB In Action 3.0
Since I have not yet started on Persistence, I think the book uses Hypersonic SQL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transacton CMT : Rollback throws exception but does not actually rollback
 
Similar Threads
How to do transaction with EJB/JPA and JDBC
JBoss JTA - Adding multiple last resources is disallowed
Two persistance-unit at persistence.xml for two database but its thows exception
Help Please, Problems connecting to multiple datasources
Trasaction not getting rolled back