Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the SQL error origin of an UnexpectedRollbackException

I have a rollback exception with hibernate on my service "duplicateContract"

Caused by: org.springframework.transaction.UnexpectedRollbackException: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException
    at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1031)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy128.duplicateContracts(Unknown Source)
    at com.test.server.rpc.SrvContractImpl.duplicateContracts(SrvContractImpl.java:699)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
    ... 34 more
Caused by: javax.transaction.RollbackException
    at org.objectweb.jotm.TransactionImpl.commit(TransactionImpl.java:329)
    at org.objectweb.jotm.Current.commit(Current.java:485)
    at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1028)
    ... 47 more

The problem is, I just can't debug that, there is an error with the persisted object somewhere but I have no clue ( it's not a timeout or missing @Transactional ). How can I get more details for this exception ? ( maybe somewhere in oracle log ? but where ? ).

like image 716
amdev Avatar asked Oct 31 '22 09:10

amdev


1 Answers

I checked the JOTM source code and, to my surprise, they don't propagate the original exception.

try {
    propagateCtx = false;
    term.commit(true);
    propagateCtx = true;
} catch (TransactionRolledbackException e) {
    Current.getCurrent().forgetTx(getXid());
    if (TraceTm.jta.isDebugEnabled()) {
        TraceTm.jta.debug("Commit distributed transaction -> rolled back!");
    }
    localstatus = Status.STATUS_ROLLEDBACK;
    throw new RollbackException();
} 
...

The JOTM project development seems to have stopped (last two releases adate back to 2006 and 2010), so you should better check Narayana, Atomikos or Bitronix.

like image 171
Vlad Mihalcea Avatar answered Nov 15 '22 03:11

Vlad Mihalcea