Spring Batch中的启动作业发生了Hibernate代理错误

时间:2012-08-15 12:41:01

标签: hibernate spring-batch spring-batch-admin


你好,我在Spring批处理应用程序中遇到了hibernate错误

ERROR: org.springframework.batch.core.job.AbstractJob - Encountered fatal error executing job
org.springframework.dao.OptimisticLockingFailureException: Attempt to update job execution id=33 with wrong version (0), where current version is 1
    at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.updateJobExecution(JdbcJobExecutionDao.java:210)
    at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:155)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy54.update(Unknown Source)
    at org.springframework.batch.core.job.AbstractJob.updateStatus(AbstractJob.java:383)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:276)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)


根据错误日志,我在Abstract Job Class(由Spring Batch提供)遇到代理错误 我想因为Abstract Job Class没有任何非参数构造函数,所以CGLIB不能提供任何代理类。
如何解决这个问题?
我现在正在使用spring batch admin

1 个答案:

答案 0 :(得分:0)

那个例外

org.springframework.dao.OptimisticLockingFailureException: Attempt to update job execution id=33 with wrong version (0), where current version is 1

表示由于某种原因您的步骤事务锁定失败。

可能导致您的业务逻辑事务被设置为RollbackOnly模式,这将导致spring表也是不一致的状态=>发生乐观锁定。

尝试为hibernate添加日志记录并显示实际的sql。这可能有助于您找出问题的实际位置。