spring-batch ItemProcessor is throwing exception when sending list of items from reader

柔情痞子 提交于 2019-12-25 08:58:53

问题


Here is the original question For CompositeItemReader Issue I have asked related to CompositeItemReader, which I resolved with help of @LucaBassoRicci, Now the Readers are working but when I am sending list of items together into my processor it is throwing an exception.

My Processor Code

@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
}

Exception I am getting.

    [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
]

Can some one let me know what is wrong with my code.

来源:https://stackoverflow.com/questions/46609625/spring-batch-itemprocessor-is-throwing-exception-when-sending-list-of-items-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!