title: chunkListener don't run when I run spring batch job
body: <p>I  use  a checkListener  and a readListener in a springBatch job for an example that I use to learn springbatch  . but when I run the job , the chunkListener don't run, only the readListener run with the job .</p>
  
  <pre><code>personChunkListener.java:
  
  
  
       package sb.dbToxml;
  
          import javax.batch.api.chunk.listener.ChunkListener;
  
          public class PersonChunkListener implements ChunkListener
          {
  
            @Override
            public void afterChunk() throws Exception
            {
              System.out.println("after chunk ....***************");
  
            }
  
            @Override
            public void beforeChunk() throws Exception
            {
              System.out.println("before chunk ....***************");
  
            }
  
            @Override
            public void onError(Exception arg0) throws Exception
            {
              // TODO Auto-generated method stub
  
            }
  
          }
  
  this is the configuration xml file for spring batch context 
  spring-batch-context.xml :
  
  
  
  
  
      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
          &lt;beans xmlns="http://www.springframework.org/schema/beans"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.springframework.org/schema/beans 
  
  
                                 http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"&gt;
  
          &lt;import resource="../jobs/jobPerson.xml" /&gt;
          &lt;import resource="../config/spring-datasource.xml" /&gt;
  
          &lt;!-- &lt;context:annotation-config /&gt; &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;a 
              PlatformTransactionManager is still required --&gt;
  
          &lt;!-- JobRepository and JobLauncher are configuration/setup classes --&gt;
          &lt;bean id="jobRepository"
              class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"&gt;
              &lt;property name="dataSource" ref="dataSourceBatch" /&gt;
              &lt;property name="transactionManager" ref="transactionManager" /&gt;
              &lt;property name="databaseType" value="oracle" /&gt;
          &lt;/bean&gt;
  
          &lt;bean id="jobLauncher"
              class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
              &lt;property name="jobRepository" ref="jobRepository" /&gt;
          &lt;/bean&gt;
  
  &lt;bean id="jobPersonListener"     class="sb.dbToxml.PersonListener" /&gt;
           &lt;bean id="personReadListener"    class="sb.dbToxml.PersonReadListener"/&gt;
           &lt;bean id="chunkListener"    class="sb.dbToxml.PersonChunkListener"/&gt;
  
  
          &lt;bean id="transactionManager"
              class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /&gt;
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>here is the main method to run the job :
      main.java</p>
  
  <pre><code>    package sb.dbToxml;
  
      import org.springframework.batch.core.Job;
      import org.springframework.batch.core.JobExecution;
      import org.springframework.batch.core.JobExecutionException;
      import org.springframework.batch.core.JobParameter;
      import org.springframework.batch.core.JobParameters;
      import org.springframework.batch.core.JobParametersBuilder;
      import org.springframework.batch.core.launch.JobLauncher;
      import org.springframework.context.ApplicationContext;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
  
      public class MainDbToXml
      {
  
        public static void main(String[] args)
        {
          ApplicationContext context=new ClassPathXmlApplicationContext("Spring/batch/config/spring-batch-contextOriginal.xml");
  
          JobLauncher jobLauncher= (JobLauncher) context.getBean("jobLauncher");
  
          Job job=(Job) context.getBean("personJob");
  
          try
          {
            JobParameters param=new JobParametersBuilder().addLong("idMax", (long) 298).toJobParameters();
  
            JobExecution execution=jobLauncher.run(job, param);
            System.out.println("Main/try :Job Person  Exit Status "+execution.getStatus());
          }
          catch (JobExecutionException e)
          {
            System.out.println("Main /catch :Job Person  failed");
            e.printStackTrace();
          }
        }
  
      }
  </code></pre>
  
  <p>this the job configuration :
  jobPerson.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:batch="http://www.springframework.org/schema/batch" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:jdbc="http://www.springframework.org/schema/jdbc"&gt;
  
      &lt;!--       *******    JdbcPagingItemReader ***** --&gt;
      &lt;bean id="itemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step"&gt;
        &lt;property name="dataSource" ref="dataSource"/&gt;
        &lt;property name="queryProvider"&gt;
          &lt;bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean"&gt;
            &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
            &lt;property name="selectClause" value="SELECT internal_Id,individual_Id "&gt;&lt;/property&gt;
            &lt;property name="fromClause" value="FROM Person"&gt;&lt;/property&gt;
            &lt;property name="whereClause" value="where internal_Id &amp;lt; :idMax"&gt;&lt;/property&gt;
            &lt;property name="sortKey" value="internal_Id"&gt;&lt;/property&gt;
          &lt;/bean&gt;
        &lt;/property&gt;
  
        &lt;property name="parameterValues"&gt;
          &lt;map&gt;
            &lt;entry key="idMax" value="#{jobParameters['idMax']}"&gt;&lt;/entry&gt;
          &lt;/map&gt;
        &lt;/property&gt;
        &lt;property name="pageSize" value="50"&gt;&lt;/property&gt;
        &lt;property name="rowMapper"&gt;
          &lt;bean class="sb.dbToxml.PersonRowMapper"&gt;&lt;/bean&gt;
        &lt;/property&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="itemWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter"&gt;
         &lt;property name="resource" value="file:xml/persons.xml"/&gt;
         &lt;property name="marshaller"  ref="personMarshaller"/&gt;
         &lt;property name="rootTagName" value="person"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="personMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
         &lt;property name="classesToBeBound"&gt;
            &lt;value&gt;sb.dbToxml.Person &lt;/value&gt;
         &lt;/property&gt;
      &lt;/bean&gt;
  
  
  
       &lt;batch:job id="personJob"&gt;
          &lt;batch:step id="step1bb1" &gt;
              &lt;batch:tasklet transaction-manager="transactionManager"&gt;
                  &lt;batch:chunk reader="itemReader" writer="itemWriter"   commit-interval="10" &gt;
                  &lt;/batch:chunk&gt;
                  &lt;batch:listeners&gt;
                   &lt;batch:listener ref="chunkListener"/&gt;
                 &lt;/batch:listeners&gt;
              &lt;/batch:tasklet&gt;
              &lt;!-- &lt;batch:listeners&gt;
                   &lt;batch:listener ref="chunkListener"/&gt;
              &lt;/batch:listeners&gt; --&gt; 
          &lt;/batch:step&gt;
          &lt;batch:listeners&gt;
                 &lt;batch:listener ref="jobPersonListener" /&gt;
                 &lt;batch:listener ref="chunkListener"/&gt;
          &lt;/batch:listeners&gt; 
  
      &lt;/batch:job&gt;
  
  
  
   &lt;/beans&gt;
  </code></pre>