我在Spring Batch工作 . 使用以下方法从CSV文件中读取

org.springframework.batch.item.file.FlatFileItemReader

并使用XML创建另一个文件并将此文件移动到另一个文件夹 . 一切都很好,但是当我尝试从文件夹中删除创建的XML文件时,我收到以下错误:

执行步骤:[removeTransferedFiles] 2017-11-15 17:05:03,305 [jobLauncherTaskExecutor-1] INFO org.springframework.batch.core.step.tasklet.TaskletStep(afterCompletion:342) - 步骤执行数据已经失败更新 . 恢复旧版本 . 2017-11-15 17:05:03,320 [jobLauncherTaskExecutor-1] ERROR org.springframework.batch.core.step.tasklet.TaskletStep(afterCompletion:351) - 在未知状态下回滚事务2017-11-15 17:05 :03,320 [jobLauncherTaskExecutor-1] INFO org.springframework.batch.core.step.ThreadStepInterruptionPolicy(isInterrupted:59) - 步骤中断StepExecution 2017-11-15 17:05:03,320 [jobLauncherTaskExecutor-1] ERROR org.springframework.batch .core.step.AbstractStep(执行:222) - 执行步骤org.springframework.batch.core.JobInterruptedException时遇到错误:检测到作业中断状态 . 在Org.springframework的org.springframework.batch.core.step.ThreadStepInterruptionPolicy.checkInterrupted(ThreadStepInterruptionPolicy.java:42)org.springframework.batch.core.step.tasklet.TaskletStep $ 2.doInChunkContext(TaskletStep.java:277) . batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)位于org.springframework.batch.repeat.support的org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367) . 在Org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)的orc.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep . )中的RepeatTemplate.executeInternal(RepeatTemplate.java:214) . java:250)atg.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)org.springframework上的org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) .batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)在Org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java: 144)org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)在org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293)的java.util上的org.springframework.batch.core.launch.support.SimpleJobLauncher $ 1.run(SimpleJobLauncher.java:120) . concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)at java.lang.Thread.run(Thread.java:745)2017-11- 15 17:05:03,320 [jobLauncherTaskExecutor-1] ERROR org.springframework.batch.core.step.AbstractStep(执行:259) - 遇到错误保存批处理元数据 . 此作业现在处于未知状态,不应重新启动 . org.springframework.dao.OptimisticLockingFailureException:尝试使用错误的版本(1)更新步骤执行id = 3,其中当前版本为2 org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:185 )在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.invoke:57 )atg.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java)中的sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606) . 317)在org.springfra的org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)的org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.transaction.intercts.TransactionInterceptor.invoke(TransactionInterceptor)中的org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)中的mework.transaction.interceptor.TransactionInterceptor $ 1.proceedWithInvocation(TransactionInterceptor.java:96) .java:94)atg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)位于com.sun.proxy的org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) . 来自org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:253)的$ Proxy19.update(未知来源)atOrg.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)位于org.springframework.batch的org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61) . core.job.flow.support.state.StepState.handle(StepState.java:60)位于org.springframework的org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) . 在org.springframework.batch的org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)中的batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) . core.job.AbstractJob.execute(AbstractJob.java:293)atg.springframework.batch.core.launch.support.SimpleJobLauncher $ 1.run(SimpleJobLauncher.java:120)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor) .java:1145)java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)at java.lang.Thread.run(Thread.java:745)2017-11-15 17:05:03,336 [ jobLauncherTaskExecutor-1] INFO org.springframew ork.batch.core.job.AbstractJob(执行:309) - 遇到中断执行作业:步骤请求终止:StepExecution:id = 3,version = 1,name = removeTransferedFiles,status = UNKNOWN,exitStatus = UNKNOWN,readCount = 0, filterCount = 0,writeCount = 0 readSkipCount = 0,writeSkipCount = 0,processSkipCount = 0,commitCount = 0,rollbackCount = 1,exitDescription = org.springframework.batch.core.JobInterruptedException

该文件实际上是从文件夹中删除但该作业之后会抛出此错误,并且永远不会获得COMPLETED状态或STOPPED状态 .

我的job.xml(或部分内容)

<job id="CSVJob" xmlns="http://www.springframework.org/schema/batch" incrementer="jobParamsIncrementer">
    <validator ref="validator" />
    <step id="writeCSVFile" next="transferToFolder" parent="chunkStep">
        <tasklet>
            <chunk reader="CSVReader" writer="XMLWriter"
                   processor="CSVProcessor" />
        </tasklet>
    </step>
    <step id="transferToFolder" next="removeTransferedFiles">
        <tasklet ref="fileTransferTasklet">
            <transaction-attributes propagation="NEVER" />                
        </tasklet>
    </step>
    <step id="removeTransferedFiles">  
        <tasklet ref="removeFileTasklet">
        </tasklet>
    </step>        
</job>

我在Spring Batch中使用相同的FlatFileItemReader进行其他工作,但我没有遇到相同的错误 . 我使用在我们的批处理通用模块中编写的removeFileTasklet,此类在其他作业中工作,在从其文件夹中删除文件后不会抛出此错误 .

为什么我会收到此错误?我知道步骤执行的版本是错误的,但是它为什么以及在哪里更新了版本以及如何防止它这样做?

我不确定你们需要多少才能回答我的问题所以请告诉我你是否需要更多信息 . 感谢您的时间 .