I read SO related questions but the solutions don\'t work for me.
I get the org.springframework.batch.item.ReaderNotOpenException: Reader must be open before i
Since you put the reader in StepScope, the bean return type should be the implementing type FlatFileItemReader:
@Bean
@StepScope
public FlatFileItemReader reader(@Value("#{jobParameters[inputZipfile]}") String inputZipfile) {
...
return reader;
}
If you specify the interface, the Spring proxy only has access to the methods and annotations specified on the interface ItemReader and is missing important annotations. There is also a warning (with a typo) in the logs:
2015-05-07 10:40:22,733 WARN [main] org.springframework.batch.item.ItemReader is an interface. The implementing class will not be queried for annotation based listener configurations. If using @StepScope on a @Bean method, be sure to return the implementing class so listner annotations can be used.
2015-05-07 10:40:22,748 WARN [main] org.springframework.batch.item.ItemReader is an interface. The implementing class will not be queried for annotation based listener configurations. If using @StepScope on a @Bean method, be sure to return the implementing class so listner annotations can be used.
Currently the Spring Boot Batch example is also returning the ItemReader, so I guess other people will struggle with the same issues.