title: java.lang.IllegalStateException when i configure FlatFileItemWriter as stream with scpoe="step" in spring batch
body: <p>I am using spring batch and am trying to configure a <code>FlatFileItemWriter</code> as a stream to log all the records that cause exception into another flat file, I need to configure the <code>scope="step"</code> so that I can use place holders for configurations.</p>
  
  <p>When i put <code>scope="step"</code> I get an exception, however when I remove it, the exception goes away.</p>
  
  <p>Here is the configuration for job:</p>
  
  <pre><code>&lt;batch:job id="helloWorldJob"&gt;
      &lt;batch:step id="step1"&gt;
          &lt;batch:tasklet&gt;
              &lt;batch:chunk reader="cvsFileItemReader" writer="cvsFileItemWriter"
                  processor="itemProcessor" commit-interval="10" skip-limit="9999"&gt;
                  &lt;batch:skippable-exception-classes&gt;
                      &lt;batch:include class="java.lang.Exception" /&gt;
                      &lt;batch:exclude class="java.io.FileNotFoundException" /&gt;
                  &lt;/batch:skippable-exception-classes&gt;
                  &lt;batch:streams&gt;
                      &lt;batch:stream ref="rejectFileItemWriter" /&gt;
                  &lt;/batch:streams&gt;
              &lt;/batch:chunk&gt;
              &lt;batch:listeners&gt;
                  &lt;batch:listener ref="skipListner" /&gt;
              &lt;/batch:listeners&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
  &lt;/batch:job&gt;
  </code></pre>
  
  <p>Here is the configuration for the skip listener with property writer:</p>
  
  <pre><code>&lt;bean id="skipListner" class="com.mykong.skipListner.RecordSkipListener"&gt;
      &lt;property name="writer" ref="rejectFileItemWriter"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here is my configuration for the writer:</p>
  
  <pre><code>&lt;bean id="rejectFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"&gt;
  
      &lt;property name="resource" value="#{jobParameters['REJECTFILE']}" /&gt;
  
      &lt;property name="lineAggregator"&gt;
          &lt;bean
              class="org.springframework.batch.item.file.transform.PassThroughLineAggregator"&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>And here is the exception that I get:</p>
  
  <pre><code>java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy2 implementing org.springframework.batch.item.file.ResourceAwareItemWriterItemStream,org.springframework.beans.factory.InitializingBean,org.springframework.batch.item.ItemWriter,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,java.io.Serializable,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 'writer': no matching editors or conversion strategy found
      at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264)
      at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:450)
      ... 17 more
  </code></pre>