Announcement Announcement Module
Collapse
No announcement yet.
Error while updating StepExecution. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while updating StepExecution.

    Hi All,
    My Main Job contains 3 Steps, the 3rd Step will dynamically gets new jobs, registers it and launches it.
    JobRegistryBackgroundJobRunner is used to launch my Main Job.

    While updating StepExecution, I am getting the following exception.

    <error>

    Sep 14, 2010 8:35:01 PM org.springframework.batch.core.step.AbstractStep execute
    SEVERE: Encountered an error executing the step
    Throwable occurred: org.springframework.transaction.TransactionSystemE xception: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:659)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:732)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:701)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:140)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:262)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:248)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:195)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:120)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:114)
    at org.springframework.batch.core.launch.support.Simp leJobOperator.start(SimpleJobOperator.java:300)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
    at org.springframework.batch.core.launch.support.Runt imeExceptionTranslator.invoke(RuntimeExceptionTran slator.java:32)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy7.start(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java :36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:48)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java :243)
    at javax.management.modelmbean.RequiredModelMBean.inv okeMethod(RequiredModelMBean.java:1086)
    at javax.management.modelmbean.RequiredModelMBean.inv oke(RequiredModelMBean.java:967)
    at org.springframework.jmx.export.SpringModelMBean.in voke(SpringModelMBean.java:88)
    at com.sun.jmx.interceptor.DefaultMBeanServerIntercep tor.invoke(DefaultMBeanServerInterceptor.java:848)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxM BeanServer.java:773)
    at javax.management.MBeanServerInvocationHandler.invo ke(MBeanServerInvocationHandler.java:300)
    at org.springframework.jmx.access.MBeanClientIntercep tor.doInvoke(MBeanClientInterceptor.java:405)
    at org.springframework.jmx.access.MBeanClientIntercep tor.invoke(MBeanClientInterceptor.java:353)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy3.start(Unknown Source)
    at za.co.sanlam.epsilon.batch.core.launch.EpsilonJobR egistryBackgroundJobRunner.start(EpsilonJobRegistr yBackgroundJobRunner.java:115)
    at za.co.sanlam.epsilon.batch.BatchInitiatorTest.test ExecuteBatch(BatchInitiatorTest.java:95)

    ..................
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: org.hibernate.TransactionException: Transaction not successfully started
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:131)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:655)
    ... 75 more
    Sep 14, 2010 8:35:01 PM org.springframework.batch.core.step.AbstractStep execute
    SEVERE: Encountered an error saving batch meta data. This job is now in an unknown state and should not be restarted.
    Throwable occurred: org.springframework.dao.OptimisticLockingFailureEx ception: Attempt to update step execution id=6889 with wrong version (1), where current version is 2
    at org.springframework.batch.core.repository.dao.Jdbc StepExecutionDao.updateStepExecution(JdbcStepExecu tionDao.java:185)
    at org.springframework.batch.core.repository.support. SimpleJobRepository.update(SimpleJobRepository.jav a:171)
    at sun.reflect.GeneratedMethodAccessor99.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:600)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :148)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy5.update(Unknown Source)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:244)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    at org.springframe

    </error>

  • #2
    Possibly there is a transaction open already when you launch your nested Job? If you use JobStep that will be taken care of for you.

    Comment


    • #3
      Thanks Dave for your suggestion.

      but we have one more problem,

      The Job to be executed will be known only in the run time. A single tasklet is used to read the jobs dynamically and registers them in the Job_Registry and starts one by one.

      1. Before starting the main job, the status of each child job is updated in Task table. While executing , even if one job fails, status of all the jobs in the task table are getting roll backed (even though the previous jobs in the list are finished successfully).
      How to commit the status of the successfully finsihed jobs before encountering an exception?

      2. In the above scenario, how to handle transactions. ?

      Comment


      • #4
        I didn't understand point #1. If you are launching jobs from a Tasklet make sure you set the transaction attributes on the Step to propagation=NOT_SUPPORTED. Longer term you might also be interested in https://jira.springsource.org/browse/BATCH-1576, or you could implement your own version of JobStep along those lines.

        Comment

        Working...
        X