1

我有一个 Spring Batch 作业开始抛出这个奇怪的异常。

我希望我有比这个堆栈跟踪更多的信息,我可能会,但我只是不知道要提供什么。

环顾四周,我只发现另一个人有这个特殊错误,但截至 2013 年 8 月没有回复。spring.io 论坛

有人有什么建议吗?谢谢/w

10:44:15,096 ERROR AbstractJob,pool-15-thread-1:326 - Encountered fatal error executing job
org.springframework.batch.core.JobExecutionException: Flow execution ended unexpectedly
        at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:141)
        at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:301)
        at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:134)
        at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
        at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:127)
        at com.example.batch.RunScheduler.run(RunScheduler.java:62)
        at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
        at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.batch.core.job.flow.FlowExecutionException: Ended flow=sourceJob at state=sourceJob.sourceStep1 with exception
        at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:161)
        at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:131)
        at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
        ... 18 more
Caused by: java.lang.IllegalStateException: Shouldn't be illegal to access field 'serialVersionUID': java.lang.IllegalAccessException: Can not set static final long field org.springframework.batch.core.StepExecution.serialVersionUID to java.lang.Long
        at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:573)
        at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:547)
        at org.springframework.batch.core.repository.dao.MapStepExecutionDao.copy(MapStepExecutionDao.java:59)
        at org.springframework.batch.core.repository.dao.MapStepExecutionDao.updateStepExecution(MapStepExecutionDao.java:109)
        at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:189)
        at sun.reflect.GeneratedMethodAccessor144.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
        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$1.proceedWithInvocation(TransactionInterceptor.java:96)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at com.sun.proxy.$Proxy61.update(Unknown Source)
        at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:183)
        at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:137)
        at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
        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:152)
        ... 20 more
4

3 回答 3

1

这似乎是 Spring 3.2.0 和其他版本中的错误。请参阅第565 行的 org.springframework.util.ReflectionUtils.doWithFields(Class,FieldCallback,FieldFilter) 的源代码。这一行的注释表明代码应该跳过静态和/或最终字段,但是没有代码来实际实现这个测试。当然,抛出的异常是尝试修改静态 final 字段的预期结果(可以通过反射修改非静态 final 字段,但静态 final 被视为编译时常量,因此不允许修改)。

于 2013-12-11T19:18:03.253 回答
0

Jules 提到的问题已修复。只需升级到 Spring Batch 版本 3.0.2.RELEASE 或更高版本。

于 2015-07-22T10:43:18.647 回答
0

如果升级到 Spring Batch Core 3.0.2 很困难(出于任何原因),并且如果您通过 Maven 使用 jacoco 集成,则解决方案可能是在 jacoco 集成中排除 Spring 类:

<pluginManagement>
    <plugins>
        <!-- Avoid BATCH-2157 until Spring Batch Core 3.0.2 -->
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>...</version>
            <configuration>
                <excludes>
                    <exclude>**/springframework/**</exclude>
                </excludes>
            </configuration>
        </plugin>
        [...]
    </plugins>
    [...]
</pluginManagement>

Maven 测试通过了;但是对代码覆盖率的影响是不合格的(这将是最小的)。

于 2016-04-08T12:09:28.677 回答