It's not a secret anymore!*
The moose likes EJB and other Java EE Technologies and the fly likes System exception on UserTransaction.commit() , followed by RollbackException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "System exception on UserTransaction.commit() , followed by RollbackException" Watch "System exception on UserTransaction.commit() , followed by RollbackException" New topic
Author

System exception on UserTransaction.commit() , followed by RollbackException

revathi balakrishnan
Greenhorn

Joined: Mar 22, 2011
Posts: 4

Hi All,
In Websphere ,I am trying to update 2 remote databases using a global transaction.

in the two remote database operations,one is to update the DB2 database and the other is to update the sql server,
First it will establish the connection in DB 2 server, it compiles the stored procedure but does not commit, then it completes the sql server updation, if the sql server updation is successful it commits initially the compiled stored procedure operation.

UserTransaction UT= new getUserTransaction();
try(
UT.begin() //global transaction begin

performDB2SPcompilation();//perform DB2 stored procedure operations , but do not commit
Issqlsuccess=perform sql server operations(); //perform sql server updation, and it will be commited



}
catch (Exception e)
{
e.PrintStackTrace();
}
finally
(
(Issqlsuccess)//if the sql server operation is successful
UT.commit() //commit the DB2 operation

}

while doing this I am getting a system exception on UT.commit() , followed by RollbackException is thrown

0000001a SystemErr javax.transaction.RollbackException
at com.ibm.ws.Transaction.JTA.TransactionImpl.stage3C ommitProcessing(TransactionImpl.java:1737)
at com.ibm.ws.Transaction.JTA.TransactionImpl.process Commit(TransactionImpl.java:1506)
at com.ibm.ws.Transaction.JTA.TransactionImpl.commit( TransactionImpl.java:1428)
at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit( TranManagerImpl.java:236)
at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(T ranManagerSet.java:157)
at com.ibm.ws.Transaction.JTA.UserTransactionImpl.com mit(UserTransactionImpl.java:285)
.


Is there anyway identify the rootcause for systemexception,or please let us know if there is a way handle this ,any help is appreciated,
Please provide me your valuable suggestions on this.Everyday at least one customer is getting affected by this issue....we have seen 25 affected cases now


thanks to every one who attempt to help me


revathi
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 515
Hello,


This does not look correct. You need to get the UserTransaction object by JNDI lookup. Isn't it?

Regds,
Amit
revathi balakrishnan
Greenhorn

Joined: Mar 22, 2011
Posts: 4

Hi Amit,
My apologies for the erroneous code above.
Initially My observation of the issue was also wrong , it is actually RollbackException and not SystemException
i have pasted my exact code and problem below .



Problem : In Websphere ,I am trying to update 2 remote databases using a global transaction.
In the two remote database operations,one is to update the DB2 database and the other is to update the SQL server,
First it will establish the connection in DB 2 server, it compiles the stored procedure but does not commit, then it completes the sql server updation, if the sql server updation is successful it commits initially the compiled stored procedure operation.

while doing this I am getting a RollbackException on userTran.commit()

0000001a SystemErr javax.transaction.RollbackException
at com.ibm.ws.Transaction.JTA.TransactionImpl.stage3C ommitProcessing(TransactionImpl.java:1737)
at com.ibm.ws.Transaction.JTA.TransactionImpl.process Commit(TransactionImpl.java:1506)
at com.ibm.ws.Transaction.JTA.TransactionImpl.commit( TransactionImpl.java:1428)
at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit( TranManagerImpl.java:236)
at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(T ranManagerSet.java:157)
at com.ibm.ws.Transaction.JTA.UserTransactionImpl.com mit(UserTransactionImpl.java:285


Could you please help me know the possibilities for getting a Rollback Exception.



i learnt that, if the transaction is marked for rollback-only, then while committing that transaction this kind of issue will occur.but i verified my code and i do not find any such explicit call to rollback. Is there any way to identify the rootcause of it . i am very new to java, please provide me the debugging tips to identify the rootcause of this issue


Code below

userTransaction getUserTransaction() // method to get the userTran object from JNDI lookup
{
UserTransaction userTran=null;

try{
InitialContext = new InitialContext();
UserTran = (UserTransaction)initCtx.lookup("java/comp/UserTransaction");
}catch(NamingException e)
{
//code to handle exception

}
return userTran;

}

void beginTransaction( UserTransaction userTran ) //method to to begin the global transaction
{
try{

userTran.begin();

} catch ()
{
//code to handle exception

}

}

void commitTransaction() //method to to commit the global transaction
{

try{

userTran.commit();//TransactionRollException occurs here [/color]

} catch ()
{
//code to handle exception

}

}


void transactionRollback() //method to rollback the global transaction
{

try{

userTran.rollback();

} catch ()
{
//code to handle exception

}

}



boolean isSqlSuccess ; //boolean to verify the sql transaction success status

UserTransaction userTran = getUserTransaction();

beginTransaction(userTran ); //global transaction begins here

try
{

updateJdbcTransaction(); // Initially perform DB2 stored procedure operations , but do not commit
isSqlSuccess =updateSqlServerTransaction(); // after that perform sql server operation on a remote server and commit it

}
Catch(Exception e)
{
//This part handles the Application exceptions
}
finally {
if(isSqlSuccess ) //if the sql server updation is succuessful,commit the pre compiled jdbc operation
commitTransaction(userTran); //Rollbackexception occurs inside this method.
else
transactionRollback(userTran);//if the sql server updation is unsuccuessful,rollback the pre compiled jdbc operation


}



Is there any way to identify the rootcause of it . i am very new to java , please provide me the debugging tips to identify the rootcause of this issue
Actual problem occurs in production and everyday our customers are getting affected beacuse of this issue .
i request your valuable suggestions friends
revathi balakrishnan
Greenhorn

Joined: Mar 22, 2011
Posts: 4

Hi all,
Finally we have fould out the rootcause for transaction rollback....it was the global transaction timeout.in websphere the default global transaction timeout is 120 seconds...if your transaction exceeds this period then it will throw the rollback exception and will rollback the global transaction.We found out this from the warning message printed in the websphere logs.
 
 
subject: System exception on UserTransaction.commit() , followed by RollbackException