弹出批处理ItemProcessor在从阅读器发送项目列表时抛出异常

时间:2017-10-06 15:56:07

标签: java spring spring-batch

以下是原始问题For CompositeItemReader Issue 我已经询问过与CompositeItemReader相关的问题,我在@LucaBassoRicci的帮助下解决了这个问题。现在读者正在工作但是当我将项目列表一起发送到我的处理器时,它会抛出异常。

我的处理器代码

@Component("fi008RecordProcessor")
@StepScope
public class FI008RecordProcessor implements ItemProcessor<List<Fi008ActvityTxnDtlsVO>, List<FI008Record>>,
    ItemProcessListener<List<Fi008ActvityTxnDtlsVO>, List<FI008Record>> {

@Value("#{jobParameters}")
private Map<String, JobParameter> jobParameters;

@Value("#{jobExecutionContext}")
private ExecutionContext jobExecutionContext;

@Autowired
private DaoHelper daoHelper;

@Override
public List<FI008Record> process(final List<Fi008ActvityTxnDtlsVO> items) throws Exception {
}

 @Override
public void beforeProcess(final List<Fi008ActvityTxnDtlsVO> item) {

}

@Override
public void afterProcess(final List<Fi008ActvityTxnDtlsVO> item, final List<FI008Record> result) {
}

@Override
public void onProcessError(final List<Fi008ActvityTxnDtlsVO> item, final Exception e) {
    // update the event table
    // update the records in settle hist table
}

我得到了例外。

    [StepExecution: id=1, version=2, name=fi08step1, status=FAILED, exitStatus=FAILED, readCount=1, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=1, exitDescription=org.springframework.batch.core.listener.StepListenerFailedException: Error in onProcessError.
       at org.springframework.batch.core.listener.MulticasterBatchListener.onProcessError(MulticasterBatchListener.java:166)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.doProcess(SimpleChunkProcessor.java:131)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.transform(SimpleChunkProcessor.java:293)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:192)
       at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
       at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
       at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:272)
       at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
       at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
       at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
       at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
       at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
       at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
       at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
       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:67)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
       at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
       at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
       at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
       at com.ent.giftcards.batch.SvcmpFI008Batch.runJob(SvcmpFI008Batch.java:58)
       at com.ent.giftcards.main.SvcmpFI008BatchApp.main(SvcmpFI008BatchApp.java:37)
Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy38 cannot be cast to com.ent.giftcards.batch.processors.FI008RecordProcessor
       at com.ent.giftcards.batch.processors.FI008RecordProcessor$$FastClassBySpringCGLIB$$f04cee7a.invoke(<generated>)
       at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
       at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
       at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
       at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
       at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
       at com.ent.giftcards.batch.processors.FI008RecordProcessor$$EnhancerBySpringCGLIB$$3fd96f10.onProcessError(<generated>)
       at org.springframework.batch.core.listener.CompositeItemProcessListener.onProcessError(CompositeItemProcessListener.java:87)
       at org.springframework.batch.core.listener.MulticasterBatchListener.onProcessError(MulticasterBatchListener.java:163)
       ... 26 more
]

有人可以让我知道我的代码有什么问题。

0 个答案:

没有答案