title: Spring Batch: not able to access jobexecutionConext in flatfileitemwriter
body: <p>hey i am trying to use the jobexecutioncontxt in my flatfileitemwriter and it shows me errors...</p>
  
  <p>My xml is:-</p>
  
  <pre><code>&lt;batch:job id="subrogationJob" incrementer="incrementer"&gt;
      &lt;batch:step id="subrogation" next="readFromDataBase"&gt;
          &lt;batch:tasklet ref="filetransferTasklet"&gt;
              &lt;batch:listeners&gt;
                  &lt;batch:listener ref="setCurrentFile" /&gt;
              &lt;/batch:listeners&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
      &lt;batch:step id="readFromDataBase" next="hasMoreFilesStep"&gt;
          &lt;batch:tasklet&gt;
              &lt;batch:chunk reader="databaseReader" processor="subrogationProcessor" writer="dbToFileItemWriter"
                  commit-interval="1" /&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
      &lt;batch:decision id="hasMoreFilesStep" decider="hasMoreFilesDecider"&gt;
          &lt;batch:fail on="FAILED" /&gt;
          &lt;batch:next on="CONTINUE" to="subrogation" /&gt;
          &lt;batch:end on="COMPLETED"/&gt;
      &lt;/batch:decision&gt;
  &lt;/batch:job&gt;
  
  &lt;bean
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations"
          value="file:${UNIQUE_DIR}/${APP_NAME}/batch/nonadj_batch.properties" /&gt;
  &lt;/bean&gt;
  
  
  
  &lt;bean id="incrementer"
      class="org.springframework.batch.core.launch.support.RunIdIncrementer" /&gt;
  
  &lt;bean id="setCurrentFile"
      class="com.hcsc.ccsp.nonadj.subrogation.batch.SubrogationInputFolderScanner"
      scope="step"&gt;
      &lt;property name="collectionParameter" value="inputFiles" /&gt;
      &lt;property name="outputFolder" value="${subrogationOutputFolder}" /&gt;
      &lt;property name="inputFolder" value="${subrogationInputFolder}" /&gt;
      &lt;property name="archiveFolder" value="${subrogationArchiveFolder}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="filetransferTasklet"
      class="com.hcsc.ccsp.nonadj.subrogation.integration.SubrogationFileTransferTasklet"
      scope="step"&gt;
      &lt;property name="inputfile" value="file:#{jobExecutionContext['inputFile']}" /&gt;
      &lt;property name="outputfile" value="file:#{jobExecutionContext['outputFile']}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="subrogationProcessor" class="com.hcsc.ccsp.nonadj.subrogation.processor.SubrogationProcessor" scope="step"&gt;
  
   &lt;/bean&gt;
  
   &lt;bean id="dbToFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"&gt;
      &lt;property name="resource" value="file:#{jobExecutionContext['outputFile']}" /&gt;
      &lt;property name="lineAggregator"&gt;
          &lt;bean class="com.hcsc.ccsp.nonadj.subrogation.writer.SubrogationLineAggregator"/&gt;
      &lt;/property&gt;
      &lt;property name="footerCallback" ref="subroHeaderFooterWriter" /&gt;
      &lt;property name="headerCallback" ref="subroHeaderFooterWriter" /&gt;
      &lt;property name="transactional" value="true" /&gt;
  
      &lt;property name="appendAllowed" value="true" /&gt; 
      &lt;property name="saveState" value="true" /&gt;
  &lt;/bean&gt;
  &lt;bean id="subroHeaderFooterWriter" class="com.hcsc.ccsp.nonadj.subrogation.writer.SubrogationHeaderFooterWriter" scope="step"&gt;
      &lt;property name="delegate" ref="dbToFileItemWriter" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="hasMoreFilesDecider"
      class="com.hcsc.ccsp.nonadj.subrogation.batch.CollectionEmptyDecider" scope="step"&gt;
      &lt;property name="collectionParameter" value="inputFiles" /&gt;
      &lt;property name="outputfile" value="file:#{jobExecutionContext['outputFile']}" /&gt;
      &lt;property name="archiveFolder" value="file:${subrogationArchiveFolder}" /&gt;
  &lt;/bean&gt;
  
  &lt;context:component-scan base-package="com.hcsc.ccsp.nonadj.subrogation.batch"
      use-default-filters="false"&gt;
      &lt;context:include-filter type="annotation"
          expression="org.springframework.stereotype.Component" /&gt;
  &lt;/context:component-scan&gt;
  
  &lt;context:annotation-config /&gt;
  
  &lt;bean id="databaseReader"
      class="org.springframework.batch.item.database.JdbcCursorItemReader"
      scope="step"&gt;
      &lt;property name="dataSource" ref="subrogrationDataSource" /&gt;
      &lt;property name="sql"
          value="SELECT QUERY" /&gt;
      &lt;property name="rowMapper"&gt;
          &lt;bean
              class="com.hcsc.ccsp.nonadj.subrogation.integration.SubrogationFieldSetMapper" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>in my listner in beforestep i put parameter in jobcontextn as</p>
  
  <p>ExecutionContext jobContext = stepExecution.getJobExecution().getExecutionContext();
  jobContext.put("outputFile", filePath);</p>
  
  <p>and in xml when i m trying to use this in xml in my writer is shows me error.....
  but it works fine filetransferTasklet.</p>
  
  <p>error is :-</p>
  
  <pre><code>                                                 O inside reader
  [5/1/14 10:41:02:303 CDT] 0000001a SystemOut     O inside processor........
  [5/1/14 10:41:02:303 CDT] 0000001a SystemOut     O inside aggregator
  [5/1/14 10:41:02:320 CDT] 0000001a AbstractStep  E org.springframework.batch.core.step.AbstractStep execute Exception while closing step execution resources
                                   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.subroHeaderFooterWriter' defined in class path resource [subrogation.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy46 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,java.io.Serializable,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.batch.item.file.FlatFileItemWriter' for property 'delegate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy46 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,java.io.Serializable,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemWriter] for property 'delegate': no matching editors or conversion strategy found
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:329)
      at org.springframework.batch.core.scope.StepScope.get(StepScope.java:150)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
      at $Proxy47.writeFooter(Unknown Source)
      at org.springframework.batch.item.file.FlatFileItemWriter.close(FlatFileItemWriter.java:282)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      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:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy46.close(Unknown Source)
      at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:83)
      at org.springframework.batch.core.step.tasklet.TaskletStep.close(TaskletStep.java:297)
      at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:264)
      at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
      at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
      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:135)
      at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293)
      at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
      at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
      at com.hcsc.ccsp.nonadj.batch.web.JobLauncherController.launch(JobLauncherController.java:64)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
  Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy46 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,java.io.Serializable,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'org.springframework.batch.item.file.FlatFileItemWriter' for property 'delegate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy46 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,java.io.Serializable,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemWriter] for property 'delegate': no matching editors or conversion strategy found
      at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
      at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
      at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
      ... 70 more
  Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy46 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,java.io.Serializable,org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.FlatFileItemWriter] for property 'delegate': no matching editors or conversion strategy found
      at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
      at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
      ... 76 more
  
  [5/1/14 10:41:02:386 CDT] 0000001a AbstractJob   E org.springframework.batch.core.job.AbstractJob execute Encountered fatal error executing job
                                   org.springframework.batch.core.JobExecutionException: Flow execution ended unexpectedly
      at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:141)
      at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:293)
      at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
      at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
      at com.hcsc.ccsp.nonadj.batch.web.JobLauncherController.launch(JobLauncherController.java:64)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
  Caused by: org.springframework.batch.core.job.flow.FlowExecutionException: Ended flow=subrogationJob at state=subrogationJob.hasMoreFilesStep with exception
      at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:152)
      at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
      at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
      ... 40 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.hasMoreFilesDecider': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
      at $Proxy45.decide(Unknown Source)
      at org.springframework.batch.core.job.flow.support.state.DecisionState.handle(DecisionState.java:43)
      at org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean$DelegateState.handle(SimpleFlowFactoryBean.java:141)
      at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
      ... 42 more
  Caused by: java.lang.IllegalStateException: No context holder available for step scope
      at org.springframework.batch.core.scope.StepScope.getContext(StepScope.java:197)
      at org.springframework.batch.core.scope.StepScope.get(StepScope.java:139)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
      ... 49 more
  
  [5/1/14 10:41:02:392 CDT] 0000001a SimpleJobLaun I org.springframework.batch.core.launch.support.SimpleJobLauncher$1 run Job: [FlowJob: [name=subrogationJob]] completed with the following parameters: [{param47=47}] and the following status: [FAILED]
  </code></pre>
  
  <p>SubrogationHeaderFooterWriter is</p>
  
  <pre><code> package com.hcsc.ccsp.nonadj.subrogation.writer;
  
      import java.io.IOException;
      import java.io.Writer;
      import org.apache.commons.lang3.StringUtils;
      import org.springframework.batch.item.file.FlatFileFooterCallback;
      import org.springframework.batch.item.file.FlatFileHeaderCallback;
      import org.springframework.batch.item.file.FlatFileItemWriter;
      import com.hcsc.ccsp.nonadj.subrogation.batch.Subrogation;
      import com.hcsc.ccsp.nonadj.subrogation.integration.SubrogationFileTransferTasklet;
      import com.hcsc.ccsp.nonadj.subrogation.processor.SubrogationProcessor;
  
      public class SubrogationHeaderFooterWriter implements  
          FlatFileFooterCallback, FlatFileHeaderCallback{
  
          SubrogationFileTransferTasklet fileTransferTasklet = new SubrogationFileTransferTasklet();
  
          private FlatFileItemWriter&lt;Subrogation&gt; delegate;
  
          public void setDelegate(FlatFileItemWriter&lt;Subrogation&gt; delegate) {
              this.delegate = delegate;
          }
  
          public FlatFileItemWriter&lt;Subrogation&gt; getDelegate() {
              return delegate;
          }
  
          /*@Override
          public void open(ExecutionContext executionContext)
                  throws ItemStreamException {
  
              this.delegate.open(executionContext);
  
          }
  
          @Override
          public void update(ExecutionContext executionContext)
                  throws ItemStreamException {
  
              this.delegate.update(executionContext);
          }
  
          @Override
          public void close() throws ItemStreamException {
  
              this.delegate.close();
          }*/
  
          @Override
          public void writeHeader(Writer writer) throws IOException {
              // TODO Auto-generated method stub
              System.out.println("inside header");
              writer.write(SubrogationFileTransferTasklet.header);
  
          }
  
          @Override
          public void writeFooter(Writer writer) throws IOException {
              // TODO Auto-generated method stub
  
  
              System.out.println("inside header");
              String trailer = SubrogationFileTransferTasklet.trailer;
              String s1 = StringUtils.substring(trailer, 0, 23);
              System.out.println("trailer without contwer is" + s1);
  
              System.out.println("whole traileer is" + s1
                      + SubrogationProcessor.totalRecords);
              System.out
                      .println("duplicate data is" + SubrogationProcessor.duplicate);
              writer.write(s1 + SubrogationProcessor.totalRecords);
  
              System.out.println("inside Footer");
  
              writer.write("Total Number of Records :: \n\n");    
  
          }
  
          /*public void write(List&lt;? extends Subrogation&gt; subrogation) throws Exception {
              System.out.println("inside writer");
  
              delegate.write(subrogation);
  
          }*/
  
      }
  </code></pre>
  
  <p>pls help....</p>