Hi!

I want to share data between steps so i decided to use the ExecutionContextPromotionListener. The problem is that my tasklet method that is annotated with @BeforeStep is not called.

My use case can be described as a step that is responsible for validating a xml file, and then share a list of validation errors to the second step that is responsible of moving the xml file to another folder but containing that list of validation errors.

After studying the example on the sprint batch guide i ended up with something like this.

First step definition
Code:
    <!-- STEP1: Validation tasklet -->
    <step id="step1">
         <tasklet>
             <beans:bean id="validationTasklet"
                         class="com....MessageValidationTasklet">
                 <beans:property name="marshaller" ref="xmlBeansMarshaller"/>
             </beans:bean>
             <listeners>
                 <listener ref="promotionListener"/>
                 <listener ref="validationListener"/>
             </listeners>
         </tasklet>
     </step>
Second step definition
Code:
<step id="invalidateFileStep">
        <tasklet>
            <beans:bean id="invalidateFileTasklet"
                        class="com....InvalidateFileTasklet"/>               
        </tasklet>
    </step>
Listeners
Code:
  <beans:bean id="promotionListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener">
        <beans:property name="keys" value="validationErrors"/>
    </beans:bean>

    <beans:bean id="validationListener"
                class="com.criticalsoftware.segurnet.batch.protocol.gs.listeners.ValidationTaskletListener"/>
The validationListener is just for returning the correct ExitStatus depending on the validation.

ValidationTasklet
Code:
public class MessageValidationTasklet implements Tasklet  

private StepExecution stepExecution;

public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
....

ExecutionContext stepContext = this.stepExecution.getExecutionContext();
stepContext.put("validationErrors", ((DefaultSaxParseErrorHandler) validator.getErrorHandler()).getValidationErrors());

}

@BeforeStep
public void saveStepExecution(StepExecution stepExecution) {
        this.stepExecution = stepExecution;
    }
Any idea about this problem?