title: Spring Batch: org.springframework.batch.item.ReaderNotOpenException: Reader must be open before it can be read
body: <p>I read SO related questions but the solutions don't work for me.</p>
  
  <p>I get the <code>org.springframework.batch.item.ReaderNotOpenException: Reader must be open before it can be read</code> exception.</p>
  
  <p>Below is my configuration:</p>
  
  <pre><code>@Bean
  @StepScope
  public ItemReader&lt;Player&gt; reader(@Value("#{jobParameters[inputZipfile]}") String inputZipfile) {
                  final String [] header = { .. this part omitted for brevity ... };
                  FlatFileItemReader&lt;Player&gt; reader = new FlatFileItemReader&lt;Player&gt;();
  
  
                  System.out.println("\t\t\t\t\t"+inputZipfile);
  
                  reader.setResource(new ClassPathResource(inputZipfile));
                  reader.setLineMapper(new DefaultLineMapper&lt;Player&gt;() {{
                      setLineTokenizer(new DelimitedLineTokenizer() {{
                          setNames( header );
                      }});
                      setFieldSetMapper(new BeanWrapperFieldSetMapper&lt;Player&gt;() {{
                          setTargetType(Player.class);
                      }});
                  }});
                  reader.setComments( header );
                  return reader;
  }
  
  @Bean
  @StepScope
  public ItemProcessor&lt;Player, PlayersStats&gt; processor(@Value("#{jobParameters[statType]}") String statType,
                                                                   @Value("#{jobParameters[season]}") String season){
                  PlayersStatsProcessor psp = new PlayersStatsProcessor();
                  psp.setStatisticType( StatisticType.valueOf(statType) );
                  psp.setSeason( season );
                  return psp;
  }
  
  
  @Bean
  @StepScope
  public ItemWriter&lt;PlayersStats&gt; writer(){
              return new CustomWriter();
  }
  
  
  @Bean
  public Job generateStatisticsJob() {
  
          return this.jobs.get("generateStatisticsJob")
                  .incrementer(new RunIdIncrementer())
                  .start(processPlayerStats())
                  //.end()
                  .build();
  }
  
  @Bean
  public Step processPlayerStats() {
             return this.steps.get("processPlayerStats")        
                          .&lt;Player, PlayersStats&gt; chunk(10)
                          .reader(reader(null))
                          .processor(processor(null,null))
                          .writer(writer())
                          .build();
  }
  </code></pre>
  
  <p>The inputZipFile variable is set properly and the file exists on the drive.
  I checked in the FlatFileItemReader code and the ReaderNotOpenException occurs when the reader member of the reader class is not set. The reader member is set in doOpen method.
  It looks that doOpen is not called. The question is why ?</p>