title: AspectJ advice not being detected in Spring application
body: <p>I had an existing WAR with the following Spring (4.0.6.RELEASE) configuration:</p>
  
  <pre><code>&lt;beans&gt;
      &lt;context:annotation-config/&gt;
      &lt;context:component-scan base-package="org.example"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>To this application I added the following annotation interface (copied verbatim):</p>
  
  <pre><code>package org.example;
  
  @Documented
  @Retention(RetentionPolicy.RUNTIME)
  @Target({ ElementType.METHOD })
  public @interface Logged {}
  </code></pre>
  
  <p>the following Aspect class (copied verbatim as well):</p>
  
  <pre><code>package org.example;
  @Aspect
  @Component
  public class LoggingAspect
  {
    @Before("@annotation(Logged)")
    public void before()
    {
      System.out.println("LoggingAspect.before()");
    }
  }
  </code></pre>
  
  <p>and the following batch processing class (copied verbatim):</p>
  
  <pre><code>package org.example;
  
  @Component
  public class Batch
  {
    @Logged
    @Scheduled(fixedDelay = 100)
    public void execute()
    {
      System.out.println("Batch.execute()");
    }
  }
  </code></pre>
  
  <p>The Spring configuration was then changed to:</p>
  
  <pre><code>&lt;beans&gt;
      &lt;aop:aspectj-autoproxy proxy-target-class="true"/&gt;
  
      &lt;context:annotation-config/&gt;
      &lt;context:component-scan base-package="org.example"/&gt;
  
      &lt;task:annotation-driven executor="executor" scheduler="scheduler"/&gt;
      &lt;task:executor id="executor" pool-size="5"/&gt;
      &lt;task:scheduler id="scheduler" pool-size="5"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>I was expecting to see the following messages on the console:</p>
  
  <pre><code>    LoggingAspect.before()
      Batch.execute()
  </code></pre>
  
  <p>However, I only see the second of these messages (that is, the aspect code is not being called).</p>
  
  <p>I took out this code to a sample application and interestingly the two messages appear just fine in the sample app.  I then compared every single file in the actual application with the sample and ensured that everything is exactly the same, including the class and file names.  Yet, the aspect does not work in the actual application.</p>
  
  <p>Upon turning on debug level logging in both applications, the sample application shows the following log message:</p>
  
  <pre><code>DEBUG org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory - Found AspectJ method: public void org.example.LoggingAspect.before()
  </code></pre>
  
  <p>but the actual application does not have this log message.  This seems to indicate that the sample app detects the aspect method but the actual app does not.  Both use the same Spring and AspectJ versions (4.0.6.RELEASE and 1.8.1 respectively).  There are no errors in either log.</p>
  
  <p><strong>Spring instantiates <code>LoggingAspect</code> in both cases (gleaned from the logs).</strong></p>
  
  <p>I have also checked various JAR dependencies for the two apps and everything is the same, except that the actual app uses Spring ORM, Hibernate and EHCACHE JARs which the sample app does not.</p>
  
  <p>Any pointers on what else should be checked will be useful.</p>