Announcement Announcement Module
Collapse
No announcement yet.
OptimisticLockingFailureException with JPA transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OptimisticLockingFailureException with JPA transaction

    Hi,

    I have this stack trace in my spring batch which use spring-data-jpa repository inside a Writer.
    I don't know if the exception is related to my spring-data-jpa or not.
    Obviously, the problem result from %PREFIX%STEP_EXECUTION table which cannot be updated.

    Any ideas why?

    Thank in advance.

    Code:
    11:02:38.700|I|TaskletStep                             |Commit failed while step execution data was already updated. Reverting to old version.
    11:02:38.700|E|TaskletStep                             |Rolling back with transaction in unknown state
    11:02:38.708|E|AbstractStep                            |Encountered an error executing the step
    org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
    	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521) ~[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    ...
    Caused by: javax.persistence.RollbackException: Transaction marked as rollbackOnly
    	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:72) ~[hibernate-entitymanager-4.1.9.Final.jar:4.1.9.Final]
    	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512) ~[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	... 22 common frames omitted
    11:02:38.717|E|AbstractStep                            |Encountered an error saving batch meta data. This job is now in an unknown state and should not be restarted.
    org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=2 with wrong version (34), where current version is 35
    	at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:185) ~[spring-batch-core-2.1.9.RELEASE.jar:na]
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:171) ~[spring-batch-core-2.1.9.RELEASE.jar:na]
    	at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source) ~[na:na]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_05]
    	at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_05]
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    ...
    11:02:38.722|I|AbstractJob                             |Encountered interruption executing job: Step requested termination: StepExecution: id=2, version=34, name=purgeRecordStep, status=UNKNOWN, exitStatus=UNKNOWN, readCount=3400, filterCount=0, writeCount=3300 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=33, rollbackCount=1, exitDescription=org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
    	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
    ...
Working...
X