Hiyas,
I am having a problem with code that used to work on the RC1 version of Spring batch...
I have a StepExecutionListener that determines whether a step should be run based on whether or not an input file was specified. The problem is that while the listener works, the step still appears to be trying to bind to the input.
Here is the @BeforeStep sequence:
The Step configuration:Code:@Override public void beforeStep(StepExecution stepExecution) { JobParameters jobParameters = stepExecution.getJobParameters(); Map<String, JobParameter> params = jobParameters.getParameters(); Steps step = Enum.valueOf(Steps.class, stepExecution.getStepName()); switch (step) { case provisionAccounts: if (!params.containsKey("accounts")) { stepExecution.setStatus(BatchStatus.ABANDONED); log.info("[Step: provisionAccounts] Input not provided... step not required."); } break; case provisionDevices: if (!params.containsKey("devices")) { stepExecution.setStatus(BatchStatus.ABANDONED); log.info("[Step: provisionDevices] Input not provided... step not required."); } break; case provisionServices: if (!params.containsKey("services")) { stepExecution.setStatus(BatchStatus.ABANDONED); log.info("[Step: provisionServices] Input not provided... step not required."); } break; case provisionEmails: if (!params.containsKey("emails")) { stepExecution.setStatus(BatchStatus.ABANDONED); log.info("[Step: provisionEmails] Input not provided... step not required."); } break; } }
And the resulting output (log):Code:<bean id="accountReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"> <property name="resource" value="file:#{jobParameters[accounts]}" /> <property name="lineMapper"> <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> <property name="lineTokenizer"> <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"> <property name="delimiter" value="|" /> <property name="names" value="billingSystem, accountNumber, vip, title, surname, givenName, postalAddress, city, state, postalCode, telephoneNumber, dstBillingTag, csgHouseKey, brdgrNode, headEnd" /> </bean> </property> <property name="fieldSetMapper"> <bean class="com.comcast.batch.domain.account.AccountMapper" /> </property> </bean> </property> </bean>
I did upgrade to the batch 2.0.1 Release version thinking fix [BATCH-1203] might have played a factor but to no avail. Can anyone suggest what the problem might be?Code:2009-06-02 11:25:38,995 [main] INFO - Job: [FlowJob: [name=BatchAccounts]] launched with the following parameters: [{emails=emails.txt}] 2009-06-02 11:25:39,057 [main] INFO - Executing step: [TaskletStep: [name=provisionAccounts]] 2009-06-02 11:25:39,070 [main] INFO - [Step: provisionAccounts] Input not provided... step not required. 2009-06-02 11:25:39,095 [main] ERROR - Encountered an error executing the step: class org.springframework.batch.item.ItemStreamException: Failed to initialize the reader org.springframework.batch.item.ItemStreamException: Failed to initialize the reader at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy7.open(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy8.open(Unknown Source) at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:98) at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:364) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195) at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348) at org.springframework.batch.core.job.flow.FlowJob.access$0(FlowJob.java:1) at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137) at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:105) at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:250) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:110) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:105) at com.comcast.batch.BatchAccountJobRunner.start(BatchAccountJobRunner.java:124) at com.comcast.batch.BatchAccountJobRunner.main(BatchAccountJobRunner.java:171) Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): URL [file:#{jobParameters[accounts]}] at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:245) at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:108) ... 40 more
I should probably state that the accounts parameter is in fact not provided and the step should be skipped. Also, removing the "file:" leader from the resource declaration still leads to:
Thanks in advance.Code:Caused by: java.lang.IllegalStateException: Cannot bind to placeholder: jobParameters[accounts]
Keith


Reply With Quote