title: Spring Batch Multiple JobExecutionListener - not working
body: <p>I have a Spring boot batch  application.
  I have two job and two different JobExecutionListener. But   always only one JobExecutionListener is called from both the job.</p>
  
  <p><strong>Job One</strong></p>
  
  <pre><code>@Configuration
  public class TestDriveJob {
  
      @Autowired
      JobLauncher jobLauncher;
  
      @Autowired
      public JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      public StepBuilderFactory stepBuilderFactory;
  
      @Autowired
      TestDriveTasklet testDriveTasklet;
  
      @Autowired
      BatchJobMgmt batchJobMgmt;
  
      @Autowired
      TestDriveJobExecutionListener testDriveJobExecutionListener;
  
      private static final String JOB_NAME = "test-drive-job";
  
      @Scheduled(fixedDelay = 100 * 1000, initialDelay = 5000)
      public void schedule() throws Exception {
          if (batchJobMgmt.isJobAllowed(JOB_NAME)) {
              JobParameters param = new JobParametersBuilder().addString("JobID", "TEST" + String.valueOf(System.currentTimeMillis())).toJobParameters();
              jobLauncher.run(job(), param);
          }
      }
  
      @Bean
      public Job job() {
          return jobBuilderFactory.get(JOB_NAME).listener(testDriveJobExecutionListener).incrementer(new RunIdIncrementer()).start(testDriveStep()).build();
      }
  
      @Bean
      public Step testDriveStep() {
          return stepBuilderFactory.get("test-drive-step").tasklet(testDriveTasklet).listener(testDriveJobExecutionListener).build();
      }
  
  }
  </code></pre>
  
  <p><strong>Job Two</strong></p>
  
  <pre><code>@Configuration
  public class ExtendedWarrantyJob {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(ExtendedWarrantyJob.class);
  
      @Autowired
      JobLauncher jobLauncher;
  
      @Autowired
      public JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      public StepBuilderFactory stepBuilderFactory;
  
      @Autowired
      ExtendedWarrantyTasklet extendedWarrantyTasklet;
  
      @Autowired
      BatchJobMgmt batchJobMgmt;
  
      @Autowired
      ExtendedWarrantyJobExecutionListener extendedWarrantyJobExecutionListener;
  
      private static final String JOB_NAME = "extended-warranty-job";
  
      @Scheduled(fixedDelay = 900 * 1000, initialDelay = 20000)
      public void schedule() throws Exception {
          if (batchJobMgmt.isJobAllowed(JOB_NAME)) {
              LOGGER.debug("Extended Warranty Job Started at :" + new Date());
              JobParameters param = new JobParametersBuilder().addString("JobID", String.valueOf(System.currentTimeMillis())).toJobParameters();
              JobExecution execution = jobLauncher.run(job(), param);
              LOGGER.debug("Extended Warranty  Job finished with status :" + execution.getStatus());
          }
      }
  
      @Bean
      public Job job() {
          return jobBuilderFactory.get(JOB_NAME).listener(extendedWarrantyJobExecutionListener).incrementer(new RunIdIncrementer()).start(extendedWarrantyStep())
                  .build();
      }
  
      @Bean
      public Step extendedWarrantyStep() {
          return stepBuilderFactory.get("extended-warranty-step").tasklet(extendedWarrantyTasklet).build();
      }
  
  }
  </code></pre>
  
  <p><strong>Job one Listener</strong></p>
  
  <pre><code>@Service
  public class TestDriveJobExecutionListener implements JobExecutionListener {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(TestDriveJobExecutionListener.class);
  
      @Override
      public void beforeJob(JobExecution jobExecution) {
          LOGGER.debug("{} Started at : {}", jobExecution.getJobInstance().getJobName(), new Date());
  
      }
  
      @Override
      public void afterJob(JobExecution jobExecution) {
          LOGGER.debug("{} Completed at : {}", jobExecution.getJobInstance().getJobName(), new Date());
      }
  
  }
  </code></pre>
  
  <p><strong>Job Two Listener</strong></p>
  
  <pre><code>@Service
  public class ExtendedWarrantyJobExecutionListener implements JobExecutionListener {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(ExtendedWarrantyJobExecutionListener.class);
  
      @Override
      public void beforeJob(JobExecution jobExecution) {
          LOGGER.debug("{} Started=== at : {}", jobExecution.getJobInstance().getJobName(), new Date());
      }
  
      @Override
      public void afterJob(JobExecution jobExecution) {
          LOGGER.debug("{} Completed at : {}", jobExecution.getJobInstance().getJobName(), new Date());
      }
  
  }
  </code></pre>
  
  <p>Both the jobs are executing without any issue. But Always the job one listener is called.  Job Two Listener is not working.
  I tried adding @Qualifier to the @@Autowired annotation, but it did not make any sense.</p>
  
  <p>any help is appreciated.</p>