This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

StepExecutionListener when the scope is STEP

May 1st, 2011, 04:10 AM

Hi,

I have noticed something. When we define the scope to be step, and that class implements StepExecutionListener, I am unable to store the reference of StepExecutionListener, which is passed in beforeStep().

I think, if I had seen my logs correctly - the beforeStep() is not called, when scope is Step.

For example, I have defined a class - Class A- which implements FlatFileFooterCallback, FlatFileHeaderCallback and StepExeutionListener. Every method is implemented.
In beforeStep(), the StepExecutionListener that is passed as an argument, I am storing a reference of it in a class variable. Would like to get the writeCount and append it in footer of file written.
In the applicationContext file, job-step-etc is defined. The writer I want to use is FlatFileItemWriter. For header and footer, defined the bean reference for Class A. the bean defining FlatFileItemWriter, is defined with scope Step.

When we run the job, everything is fine - but a NullPointerException occurs when I say this.stepExecutionListener.getWriteCount(). On putting some debug statement in beforeStep(), the method is not called.