Failed to run batchlet with javax.transaction.NotSupportedException: WFTXN0001: A transaction is already in progress
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
Issue
- When invoking a batchlet, the following error occurred.
WARN [org.jberet] (Batch Thread - 2) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact@3457ab00: javax.transaction.NotSupportedException: WFTXN0001: A transaction is already in progress
at org.wildfly.transaction.client.ContextTransactionManager.begin(ContextTransactionManager.java:60)
at org.wildfly.transaction.client.LocalUserTransaction.begin(LocalUserTransaction.java:48)
at org.jboss.as.quickstarts.batch.job.ReportBatchelet.process(ReportBatchelet.java:53)
at org.jberet.runtime.runner.BatchletRunner.run(BatchletRunner.java:72)
at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:229)
at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:147)
at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
at org.jberet.runtime.runner.CompositeExecutionRunner.runJobElement(CompositeExecutionRunner.java:128)
at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:203)
at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)
at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:60)
at org.wildfly.extension.batch.jberet.deployment.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:184)
at org.wildfly.extension.requestcontroller.RequestController$QueuedTask$1.run(RequestController.java:497)
at org.jberet.spi.JobExecutor$3.run(JobExecutor.java:161)
at org.jberet.spi.JobExecutor$1.run(JobExecutor.java:99)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Resolution
Please make sure to do commit/rollback finally for UserTransaction in your batchlet.
Root Cause
If not to do commit/rollback appropriately for UserTransaction in batchlet, transaction information remains into the thread.
WFTXN0001: A transaction is already in progress
would be occurred when using the thread next time.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments