AnsweredAssumed Answered

Transaction rollback in activiti job

Question asked by nicolas1 on Aug 25, 2014
Latest reply on May 27, 2018 by leroux@itldev.fr
Hi,

I have a JavaDelegate which calls a JPA/JTA service (OSGi).
If an exception is raised in the JPA layer, the transaction is rolled back. But then an issue occurs in activiti because it tries to add a transaction listener when catching the original exception :

org.activiti.engine.ActivitiException: RollbackException while registering synchronization
   at org.activiti.engine.impl.cfg.jta.JtaTransactionContext.addTransactionListener(JtaTransactionContext.java:76)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:85)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:64)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)[105:org.activiti.engine:5.16.0]
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:52)[105:org.activiti.engine:5.16.0]
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_25]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_25]
   at java.lang.Thread.run(Thread.java:724)[:1.7.0_25]
Caused by: javax.transaction.RollbackException: Transaction is marked for rollback
   at org.apache.geronimo.transaction.manager.TransactionImpl.registerSynchronization(TransactionImpl.java:154)[74:org.apache.aries.transaction.manager:1.1.0]
   at org.activiti.engine.impl.cfg.jta.JtaTransactionContext.addTransactionListener(JtaTransactionContext.java:72)[105:org.activiti.engine:5.16.0]
   … 11 more

As a result the job retries is not decremented and the original exception is hidden.
I think Activiti should be able to handle properly this case, but maybe I am doing something wrong ?

Nicolas

Outcomes