Thanks for replying.
I know its sound weird but I tried to make this work for 4 hours but suddenly now its started working after adding 'strict' property to the promotionlistener for sometime. then again stopped working.
Here is my code.
In the first step of my job I am loading the values in the context.
In the second step , am trying to get it from jobcontextCode:public class MyMultiResourceItemReader extends MultiResourceItemReader { . . . @Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); try { if (getCurrentResource()!=null) { executionContext.put("current.resource.dir.path", getCurrentResource().getFile().getParentFile()); executionContext.put("current.resource.name", getCurrentResource().getFilename()); } else { executionContext.put("current.resource.dir.path", null); executionContext.put("current.resource.name", null); } } catch (Exception e) { logger.error(e.getMessage(), e); } } @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); try { if (getCurrentResource()!=null) { executionContext.put("current.resource.dir.path", getCurrentResource().getFile().getParentFile()); executionContext.put("current.resource.name", getCurrentResource().getFilename()); } else { executionContext.put("current.resource.dir.path", null); executionContext.put("current.resource.name", null); } } catch (Exception e) { logger.error(e.getMessage(), e); } } }
this is my step 3,Code:public class ProcessorTasklet implements Tasklet { private String fileName = null; public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception { StepContext stepContext = arg1.getStepContext(); StepExecution stepExecution = stepContext.getStepExecution(); JobExecution jobExecution = stepExecution.getJobExecution(); ExecutionContext jobContext = jobExecution.getExecutionContext(); this.fileName = (String) jobContext.get("current.resource.name"); . . . return null; } @BeforeStep public void getData(StepExecution stepExecution) { JobExecution jobExecution = stepExecution.getJobExecution(); ExecutionContext jobContext = jobExecution.getExecutionContext(); this.fileName = (String) jobContext.get("current.resource.name"); } }
Code:public class FileMoveTasklet implements Tasklet { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { File dirParent; StepContext stepContext = chunkContext.getStepContext(); StepExecution stepExecution = stepContext.getStepExecution(); JobExecution jobExecution = stepExecution.getJobExecution(); ExecutionContext jobContext = jobExecution.getExecutionContext(); dirParent = (File) jobContext.get("current.resource.dir.path"); String fileNem = (String) jobContext.get("current.resource.name"); . . . return RepeatStatus.FINISHED; } }Code:<bean id="promotionListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener" scope="step"> <property name="keys" > <list> <value>current.resource.name</value> <value>current.resource.dir.path</value> </list> </property> <property name="strict" value="true"/> </bean>


Reply With Quote