In my application we are using TX Manager.
My application is built on JSF and RF3.3 with JDBC connectivity to MYSQL
Here’s the scenario:-
- User enter value on GUI.
- after collecting all data in Backing Bean I get the instance of Transaction Manager.
- Then i begin the TX.
- All the values are inserted in DB1.
- SOAP call is made to insert values in another DB2.
- In case insertion in DB2 fails entry from DB1 should roll back.
7.For this I use tx.rollBack().
Problem is although tx.rollBack is executed even then the entry is not removed.
I tried declaring afterRollBackAction and fired a delete query in DB1 but it gives me an exception
org.jboss.util.NestedSQLException: Transaction TransactionImple < ac, BasicAction: a7c198d:6:4eccc549:a status: ActionStatus.ABORTED > cannot proceed STATUS_ROLLEDBACK; - nested throwable: (javax.transaction.RollbackException: Transaction TransactionImple < ac, BasicAction: a7c198d:6:4eccc549:a status: ActionStatus.ABORTED > cannot proceed STATUS_ROLLEDBACK)
I checked my code properly..There is not exception (NPE or SQL or Any other kind of exeption thrown)..
Can you please tell me why the TX is not rolling back and deleting entry from the DB1?
Code Snippet :-
try
{
txManager.begin()
cStmt.setString(1,Name);
cStmt.setString(2,Address);
cStmt.setString(3,Number);
cStmt.registerOutParameter(10, java.sql.Types.INTEGER);
cStmt.execute();
int errorCode=cStmt.getShort(10);
if(errorCode==0)
{
WebService Stub =new WebServiceStub();
CreateIdentity create=new CreateIdentity();
create.setName(Name);
create.setAddress(Address);
create.setNumber(Number);
CreateIdentityResponse createResponse=stub.createIdentity(create);
int errorCodeFromWebService=createResponse.getMsg();
switch(errorCodeFromWebService)
{
case 0:
errorCode=0;
txmanager.commit();
break;
case -1:
txManager.rollback();
break;
default:
txManager.rollback();
}
else
{
txManager.rollback();
}
return errorCode;
Although txManager.rollback gets called but rollback itself is not happening. I tried using actions before and after rollback but to no avail.
As @Mark Rotteveel pointed out if your tables use MyIsam engine transactions does not work. If you are using InnoDB engine check the autocommit property of your jdbc connection/jdbc driver, it should be set to false.