title: Implementation of ApplicationListener<ContextRefreshedEvent> prevents registration of @Scheduled & @Async methods
body: <p>I have a Service class in which I wish to invoke a method after the application context has been initialized and ALL the beans &amp; annotations have been initialized and registered respectively:</p>
  
  <pre><code>    @Service
      public class EventGenerator implements ApplicationListener&lt;ContextRefreshedEvent&gt;{
  
          static Logger logger = Logger.getLogger(EventGenerator.class);
  
          @Autowired
          private JsonQueryService service;
  
          @Override
          public void onApplicationEvent(ContextRefreshedEvent event) {
  
             generateFlights();
  
          }
  
          @Async
          private void generateFlights(){
  
              while(true){
  
                   try{  
  
                      List&lt;FlightJson&gt; jsons = service.parseJSONFeed();
  
                      checkHexcodeAndMappings(jsons);
  
                      updateSquark(jsons);
  
                          Thread.sleep(10000);   
  
                        }catch(InterruptedException e){  
                              e.printStackTrace();  
                        }  
  
                      }       
              }
  
    }
  </code></pre>
  
  <p>I also have other @Scheduled and @Async annotations in the application. What I don't understand is why when I call the <em>generateFlights()</em> method, ALL the @Scheduled and @Async annotations in the application are <strong>not</strong> registered. </p>
  
  <p>If I <strong>do not</strong> call the <em>generatFlights()</em> method within the <em>onApplicationEvent(ContextRefreshedEvent event)</em> method, then the annotated methods are registered normally and the respective cron tasks / asynchronous methods run normally.</p>
  
  <p>Here is the root application context body (without namespace declarations):</p>
  
  <pre><code>&lt;context:component-scan base-package="com.atlaschase.product.core"&gt;
          &lt;context:exclude-filter type="regex"
              expression="com.atlaschase.product.core.bootstrap.populators.*" /&gt;
          &lt;context:exclude-filter type="regex"
              expression="com.atlaschase.product.core.services.jms.*" /&gt;
          &lt;context:exclude-filter type="regex"
              expression="com.atlaschase.product.core.services.processor.*" /&gt;
          &lt;context:exclude-filter type="regex"
              expression="com.atlaschase.product.core.services.remote.*" /&gt;           
      &lt;/context:component-scan&gt;
  
      &lt;import resource="classpath:core-properties.xml" /&gt;
      &lt;import resource="classpath:core-datasource.xml" /&gt;
      &lt;import resource="classpath:core-task-scheduler.xml" /&gt;
  </code></pre>
  
  <p>Here is the <em>core-task-scheduler.xml</em> application context which contains details of executor configuration (again, namespaces ommitted):</p>
  
  <pre><code>&lt;task:annotation-driven executor="executor" scheduler="scheduler"/&gt;
      &lt;task:executor id="executor" pool-size="1"/&gt;
      &lt;task:scheduler id="scheduler" pool-size="5"/&gt;
  </code></pre>
  
  <p>Any insight into why this might be happening would be appreciated.</p>
  
  <p>Thanks</p>