3

很抱歉,我无法提供有关受错误影响的批次的很多信息。

当 XML 输入文件位于正确的存储库中时,我想大致了解什么会导致初始化阅读器时出错。spring batch v1和spring batch v2在初始化普通简单步骤的reader进程时有什么变化吗?

几天前,我们将批次迁移到 Spring Batch V2。

错误 org.springframework.batch.core.step.AbstractStep [] 执行步骤 org.springframework.batch.item.ItemStreamException 时遇到错误:无法在 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open( AbstractItemCountingItemStreamItemReader.java:142) 在 org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:96) 在 org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:306)在 org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:192) 在 org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:137) 在 org.springframework.batch.core .job.flow.JobFlowExecutor。executeStep(JobFlowExecutor.java:64) 在 org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) 在 org.springframework.batch.core.job.flow.support. SimpleFlow.resume(SimpleFlow.java:152) 在 org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:131) 在 org.springframework.batch.core.job.flow.FlowJob。 doExecute(FlowJob.java:135) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:301) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java :134) 在 org.springframework.batch.core.launch.support 的 org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)。SimpleJobLauncher.run(SimpleJobLauncher.java:127) at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:351) at org.springframework.batch.core.launch.support.CommandLineJobRunner.main( CommandLineJobRunner.java:577)引起:java.lang.IllegalStateException:输入资源必须存在(阅读器处于“严格”模式)在 org.springframework.batch.item.xml.StaxEventItemReader.doOpen(StaxEventItemReader.java:187) 在org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139) ... 还有 15 个java:351) at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:577) 原因:java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode) at org.springframework.batch.item.xml.StaxEventItemReader.doOpen(StaxEventItemReader.java:187) 在 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139) ... 15 更多java:351) at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:577) 原因:java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode) at org.springframework.batch.item.xml.StaxEventItemReader.doOpen(StaxEventItemReader.java:187) 在 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139) ... 15 更多doOpen(StaxEventItemReader.java:187) 在 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139) ... 还有 15 个doOpen(StaxEventItemReader.java:187) 在 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139) ... 还有 15 个

4

2 回答 2

5

Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode不言自明,资源丢失并且设置“严格”模式将导致错误
如果您确定资源在正确的位置,请检查您是否使用正确的语法来识别您的资源路径(文件:,类路径:,url:或Spring支持的其他人)?

于 2013-11-08T15:04:34.310 回答
4

在 org.springframework.batch.item.xml.StaxEventItemReader bean 中将属性 strict 设置为 false,如下所示:

<property name="strict" value="false" />

这将记录 Spring 试图查找的路径(这对于调试此类错误非常有用):

WARN: StaxEventItemReader.doOpen() - Input resource does not exist class path resource [path-to-resource]

但是,strict=false 将导致 StaxEventItemReader 不再抛出异常(因此您可能希望之后将 StaxEventItemReader 更改回 strict=true)。

于 2014-04-25T05:42:38.583 回答