Announcement Announcement Module
No announcement yet.
StepExecutionListener when the scope is STEP Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • StepExecutionListener when the scope is STEP


    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.

    Remove scope Step, and I think it starts working.
    Any idea why?