Reputation: 43
I've got the below error when I try to start spring boot application. It gives an error even before I provide my job parameter which is a parameter for my job.
Lot of discussion suggest to use resource as file:#{jobParameters[controlFileInput]}
to solve this. But it's not working for me. Thanks in advance.
batch xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<context:property-placeholder location="classpath:application.properties" />
<bean id="stepScope" class="org.springframework.batch.core.scope.StepScope">
<property name="autoProxy" value="true" />
</bean>
<bean id="billItemWriteListener"
class="com.telstra.billubfreader.listener.BillItemWriteListener" />
<bean id="billItemProcessListener"
class="com.telstra.billubfreader.listener.BillItemProcessListener" />
<bean id="fileMovingToErrorTasklet"class="com.telstra.billubfreader.ErrorFileMover" />
<bean id="fileMovingToSuccessTasklet"
class="com.telstra.billubfreader.SuccessFileMover" />
<bean id="billControlFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader"
scope="step">
<property name="resource" value="file:#{jobParameters[controlFileInput]}" />
<property name="linesToSkip" value="${control.linetoskip}" />
<property name="lineMapper">
<bean class="com.telstra.billubfreader.mapper.BillControlLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="com.telstra.billubfreader.mapper.BillControlFieldDataMapper" />
</property>
</bean>
</property>
</bean>
<bean id="billControlItemProcessor" class="com.telstra.billubfreader.BillControlItemProcessor"
scope="step">
</bean>
<bean id="billControFileItemwriter" class="com.telstra.billubfreader.BillControlItemWriter"
scope="step">
</bean>
<batch:job id="billControlFileReaderJob" restartable="true">
<batch:step id="billControlFileRaderStep1">
<batch:tasklet>
<batch:chunk reader="billControlFileItemReader"
processor="billControlItemProcessor" writer="billControFileItemwriter"
commit-interval="25">
<batch:listeners>
<batch:listener ref="billItemWriteListener" />
<batch:listener ref="billItemProcessListener" />
<batch:listener ref="promotionListener"/>
</batch:listeners>
</batch:chunk>
</batch:tasklet>
<batch:next on="FAILED" to="fileMovingtoError" />
<batch:next on="COMPLETED" to="fileMovingToSuccess" />
</batch:step>
<batch:step id="fileMovingtoError">
<tasklet ref="fileMovingToErrorTasklet"/>
</batch:step>
<batch:step id="fileMovingToSuccess">
<tasklet ref="fileMovingToSuccessTasklet"/>
</batch:step>
</batch:job>
<bean id="promotionListener"
class="org.springframework.batch.core.listener.ExecutionContextPromotionListener">
<property name="keys" value="filesToMove"/>
</bean>
</beans>
logs
2018-04-25 12:10:05.779 INFO 22716 --- [ main] o.s.batch.core.job.SimpleStepHandler : Step already complete or not restartable, so no action to execute: StepExecution: id=1, version=15, name=billControlFileRaderStep1, status=ABANDONED, exitStatus=FAILED, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=0, exitDescription=org.springframework.batch.item.ItemStreamException: Failed to initialize the reader at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:149) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy52.open(Unknown Source) at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:103) at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:310) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197) at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:66) 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:136) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:308) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:141) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:134 2018-04-25 12:10:06.201 INFO 22716 --- [ main] o.s.batch.core.job.SimpleStepHandler : Step already complete or not restartable, so no action to execute: StepExecution: id=2, version=3, name=fileMovingtoError, status=COMPLETED, exitStatus=COMPLETED, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription= 2018-04-25 12:10:06.334 INFO 22716 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=billControlFileReaderJob]] complet
Upvotes: 1
Views: 1026
Reputation: 43
I found the issue here.issue was SpringApplication.run
execute the job before I launch the job. So, its without job param. set spring.batch.job.enabled=false solved the issue.
Upvotes: 2