org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction

Spring JIRA | Praveen Kumar Battu | 7 years ago
  1. 0

    [BATCH-1307] MapJobRepository with multi-threaded parallel steps (split in job) - Spring JIRA

    spring.io | 1 year ago
    org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction
  2. 0

    I am trying to execute a job which is divided into two different steps. Step1: Read the data from a xml file (using JAXB for un-marshaling of the xml data) Step 2: Business processing of the Data (which intern contains multiple steps), As each business processing steps are independent to each other, due to this I am parallel process them using <split> and <flow> elements as described below. <job id="ParallelJobProcessing" job-repository="jobRepository"> <step id="main" next="split1"> <tasklet> <chunk reader="eventLogReader" processor="eventLogProcessor" writer="dummyFlatFileWriter" commit-interval="12000" /> </tasklet> </step> <split id="split1" task-executor="asyncTaskExecutor" > <flow> <step id="totalEventCount"> <tasklet ref="totalEventCountTaskRef"/> </step> </flow> <flow> <step id="allowedEventCount"> <tasklet ref="allowedEventCountref"/> </step> </flow> </split> <listeners> <listener ref="jobTimeRecorderRef" /> </listeners> </job> <beans:bean id="asyncTaskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" /> When I add a Task Executor to split tag I am receiving following exception, please let me know what needs to be done to solve the above issue. org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:795) at org.springframework.batch.core.step.tasklet.TaskletStep.rollback(TaskletStep.java:368) at org.springframework.batch.core.step.tasklet.TaskletStep.access$1000(TaskletStep.java:68) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:309) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:82) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:80) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 15:59:35,484 DEBUG TaskletStep:299 - Saving step execution after commit: StepExecution: id=2, name=allowedEventCount, status=STARTED, exitStatus=EXECUTING, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, commitCount=1, rollbackCount=0, exitDescription= 15:59:35,484 DEBUG ResourcelessTransactionManager:371 - Creating new transaction with name [org.springframework.batch.core.repository.JobRepository.update]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 15:59:35,484 ERROR AbstractStep:213 - Encountered an error executing the step: class org.springframework.batch.core.step.AbstractStep$FatalException: Fatal failure detected org.springframework.batch.core.step.AbstractStep$FatalException: Fatal failure detected at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:303) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:82) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:80) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=1 with wrong version (1), where current version is 0 at org.springframework.batch.core.repository.dao.MapStepExecutionDao.updateStepExecution(MapStepExecutionDao.java:86) at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy2.update(Unknown Source) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:300) ... 17 more Please find the attachments (normal log and error log) for the complete log information without task-executor and with.

    Spring JIRA | 7 years ago | Praveen Kumar Battu
    org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction
  3. 0

    I am trying to execute a job which is divided into two different steps. Step1: Read the data from a xml file (using JAXB for un-marshaling of the xml data) Step 2: Business processing of the Data (which intern contains multiple steps), As each business processing steps are independent to each other, due to this I am parallel process them using <split> and <flow> elements as described below. <job id="ParallelJobProcessing" job-repository="jobRepository"> <step id="main" next="split1"> <tasklet> <chunk reader="eventLogReader" processor="eventLogProcessor" writer="dummyFlatFileWriter" commit-interval="12000" /> </tasklet> </step> <split id="split1" task-executor="asyncTaskExecutor" > <flow> <step id="totalEventCount"> <tasklet ref="totalEventCountTaskRef"/> </step> </flow> <flow> <step id="allowedEventCount"> <tasklet ref="allowedEventCountref"/> </step> </flow> </split> <listeners> <listener ref="jobTimeRecorderRef" /> </listeners> </job> <beans:bean id="asyncTaskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" /> When I add a Task Executor to split tag I am receiving following exception, please let me know what needs to be done to solve the above issue. org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:795) at org.springframework.batch.core.step.tasklet.TaskletStep.rollback(TaskletStep.java:368) at org.springframework.batch.core.step.tasklet.TaskletStep.access$1000(TaskletStep.java:68) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:309) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:82) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:80) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 15:59:35,484 DEBUG TaskletStep:299 - Saving step execution after commit: StepExecution: id=2, name=allowedEventCount, status=STARTED, exitStatus=EXECUTING, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, commitCount=1, rollbackCount=0, exitDescription= 15:59:35,484 DEBUG ResourcelessTransactionManager:371 - Creating new transaction with name [org.springframework.batch.core.repository.JobRepository.update]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 15:59:35,484 ERROR AbstractStep:213 - Encountered an error executing the step: class org.springframework.batch.core.step.AbstractStep$FatalException: Fatal failure detected org.springframework.batch.core.step.AbstractStep$FatalException: Fatal failure detected at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:303) at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67) at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352) at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212) at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:82) at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:80) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=1 with wrong version (1), where current version is 0 at org.springframework.batch.core.repository.dao.MapStepExecutionDao.updateStepExecution(MapStepExecutionDao.java:86) at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:167) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy2.update(Unknown Source) at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:300) ... 17 more Please find the attachments (normal log and error log) for the complete log information without task-executor and with.

    Spring JIRA | 7 years ago | Praveen Kumar Battu
    org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Transaction is already completed - do not call commit - Spring Forum

    spring.io | 1 year ago
    org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction
  6. 0

    JBPM 5.4 using custom class object as parameter in signal event

    Stack Overflow | 3 years ago | Ajay
    java.lang.RuntimeException: Could not commit session or rollback

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.transaction.IllegalTransactionStateException

      Transaction is already completed - do not call commit or rollback more than once per transaction

      at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback()
    2. Spring Tx
      AbstractPlatformTransactionManager.rollback
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:795)
      1 frame
    3. Spring Batch Core
      StepContextRepeatCallback.doInIteration
      1. org.springframework.batch.core.step.tasklet.TaskletStep.rollback(TaskletStep.java:368)
      2. org.springframework.batch.core.step.tasklet.TaskletStep.access$1000(TaskletStep.java:68)
      3. org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:309)
      4. org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67)
      4 frames
    4. Spring Batch Infrastructure
      RepeatTemplate.iterate
      1. org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352)
      2. org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
      3. org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
      3 frames
    5. Spring Batch Core
      SplitState$1.call
      1. org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239)
      2. org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
      3. org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348)
      4. org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
      5. org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137)
      6. org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
      7. org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
      8. org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
      9. org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:82)
      10. org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:80)
      10 frames
    6. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      2. java.util.concurrent.FutureTask.run(Unknown Source)
      3. java.lang.Thread.run(Unknown Source)
      3 frames