title: Why doesn't AspectJ compile-time weaving of Spring's @Configurable work?
body: <p><strong>Update 5:</strong> I've downloaded the latest Spring ToolsSuite IDE based on the latest Eclipse. When I import my project as a Maven project, Eclipse/STS appears to use the Maven goals for building my project. This means AspectJ finally works correctly in Eclipse.</p>
  
  <p><strong>Update 4:</strong> I have ended up just using Maven + AspectJ plugin for compile-time weaving, effectively bypassing Eclipse's mechanism.</p>
  
  <p><strong>Update 3:</strong> It seems AspectJ's Eclipse plug-in breaks Eclipse's ability to correctly Publish to Tomcat. Only by removing the AspectJ capability on a project can I get it to properly Publish again. Very annoying.</p>
  
  <p><strong>Update 2:</strong> I have this now working in Eclipse. It makes me very uncomfortable to say this, but I have no idea how I got it working from either Eclipse or Maven builds. It appears to be a compile issue rather than a run-time issue.</p>
  
  <p><strong>Update 1:</strong> It appears I've gotten this to work via Maven builds, but I have no idea how. Eclipse still doesn't work. The only thing I changed in the <em>pom.xml</em> was adding these (insignificant?) configuration parameters:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;source&gt;1.6&lt;/source&gt;
  &lt;complianceLevel&gt;1.6&lt;/complianceLevel&gt;
  &lt;verbose&gt;true&lt;/verbose&gt;
  &lt;showWeaveInfo&gt;true&lt;/showWeaveInfo&gt;
  &lt;outxml&gt;true&lt;/outxml&gt;
  </code></pre>
  
  <p>I'm actually worried that I have a repeat of <a href="https://stackoverflow.com/questions/828747/why-does-springs-configurable-sometimes-work-and-sometimes-not">this problem</a>, where everything works inconsistently. I will keep this question updated as I learn more.</p>
  
  <p>With regards to Eclipse, I made some progress by taking the binary aspects I wish to weave - in this case <em>spring-aspects.jar</em> - and copying it out of my classpath. I then add this now external jar to my <strong>Aspect Path</strong>. After doing this, Eclipse properly shows me AspectJ markers in my code. It's annoying that I can't just leave <strong>spring-aspects.jar</strong> in my <strong>Java Build Path</strong> which is maintained by Maven for me via the Maven plug-in. For some reason, however, the AspectJ plug-in doesn't see the binary aspects unless they're explicitly added to the <strong>Aspect Path</strong>.</p>
  
  <hr>
  
  <p><strong>Original Post:</strong> @Configurable is a Spring annotation that allows dependencies to be injected into objects instantiated external to Spring (for example, by Hibernate or some Factory class).</p>
  
  <p>I was using this annotation previously with load-time weaving and it <em>mostly</em> worked. Occasionally I would boot up and nothing would get injected. This issue spawned <a href="https://stackoverflow.com/questions/828747/why-does-springs-configurable-sometimes-work-and-sometimes-not">this StackOverflow question</a>. There weren't many answers, but most suggested that I try compile-time weaving instead due to greater reliability.</p>
  
  <p>I installed the AspectJ plug-in for Eclipse and Maven. Both of these produce what appears to be properly compiled classes. I've opened up one of the classes in a text editor before AspectJ compilation and found no references to AspectJ. I opened it up after AspectJ compilation and both Eclipse and Maven generated versions have a reference to <strong>org.aspectj.weaver.MethodDeclarationLineNumber</strong>. This is why I assume it's being properly compiled. The problem is that once deployed, no dependencies get injected. </p>
  
  <p>My Spring <em>applicationContext.xml</em> does include the following:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;context:spring-configured /&gt;
  
      &lt;context:component-scan base-package="com.myapp" /&gt;
  </code></pre>
  
  <p>Is the above all that's needed for classes marked @Configurable to have DI done? During the conversion from load-time weaving to compile-time weaving, I removed <em>META-INF/aop.xml</em>, <em>&lt;context:load-time-weaver /></em> from my <em>applicationContext.xml</em>, and Spring's Tomcat weaver from my <em>context.xml</em>.</p>
  
  <p>How can I investigate this problem further? What are possible causes?</p>