title: Simple @Configurable with modern spring-boot + gradle
body: <p>My goal is to get a bare bones aspectj+spring aop setup such that I can use @Configurable on one class. One additional restriction is that it needs to use load-time weaving as Lombok doesn't work with CTW.</p>
  
  <p>The good news: I have it working! </p>
  
  <p>The bad news: The console is flooded with <code>[Xlint:cantFindType]</code> errors. See results section below.</p>
  
  <h1>The Environment</h1>
  
  <p>I have a single class annotated with <code>@Configurable</code>. It is a class used by and instantiated by Jackson, hence the need for AOP. It's not very interesting so I won't show it here. It's just a normal class with the single annotation of Configurable, and an <code>@Autowired</code> bean inside.</p>
  
  <h2>SpringBootApplication</h2>
  
  <p>My Application class has the usual annotations:</p>
  
  <pre><code>@SpringBootApplication
  @EnableSpringConfigured
  @EnableLoadTimeWeaving
  public class MyApplication {
  </code></pre>
  
  <h2>build.gradle</h2>
  
  <p>My build.gradle has all the usual suspects. Sample:</p>
  
  <pre><code>configurations {
      springinstrument
  }
  
  dependencies {
      compile('org.projectlombok:lombok')
  
      compile('org.springframework.boot:spring-boot-starter-aop')
      compile("org.springframework.boot:spring-boot-starter-data-rest")
      compile('org.springframework.data:spring-data-rest-hal-browser')
      compile('org.springframework.boot:spring-boot-starter-data-jpa')
      compile('org.springframework.boot:spring-boot-starter-security')
      compile('org.springframework.boot:spring-boot-starter-web')
      compile('org.springframework.boot:spring-boot-devtools')
      compile('org.springframework.plugin:spring-plugin:1.2.0.RELEASE')
  ..snip..
      runtime('org.springframework:spring-instrument:4.+')
      springinstrument "org.springframework:spring-instrument:4.+"
      runtime configurations.springinstrument.dependencies
  }
  
  test.doFirst {
      jvmArgs "-javaagent:${configurations.springinstrument.asPath}"
  }
  </code></pre>
  
  <h2>jvm args</h2>
  
  <p>I am running a JUnit test with the following args (via Intellij's run config)</p>
  
  <pre><code>-ea
  -javaagent:/Users/me/.gradle/caches/modules-2/files-2.1/org.springframework/spring-instrument/4.3.3.RELEASE/5db399fa5546172b9c107817b4abaae6b379bb8c/spring-instrument-4.3.3.RELEASE.jar
  </code></pre>
  
  <h2>aop.xml</h2>
  
  <p>I have a <code>src/main/resources/META-INF/aop.xml</code> containing:</p>
  
  <pre><code>&lt;!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"&gt;
  &lt;aspectj&gt;
          &lt;weaver options="-Xreweavable -showWeaveInfo"&gt;
          &lt;!-- only weave classes with @Configurable interface --&gt;
          &lt;include within="@org.springframework.beans.factory.annotation.Configurable */&gt;
      &lt;/weaver&gt;
  &lt;/aspectj&gt;
  </code></pre>
  
  <p>However, my suspicion is that this file is not being picked up. It doesn't matter what I put in the file, the results are always the same. Even if I put random non-valid XML.</p>
  
  <h2>The Test</h2>
  
  <p>The junit test is a simple Jackson serialize-deserialize test using the <code>@Configurable</code> annotated class.</p>
  
  <p>The test class has the annotations:</p>
  
  <pre><code>@SpringBootTest
  @RunWith(SpringRunner.class)
  </code></pre>
  
  <h1>The Results</h1>
  
  <h2>When running a junit test via Intellij -> It Works, but..</h2>
  
  <p>The LTW is actual working and my test is passing when run via Intellij with the jvm args above.</p>
  
  <p>However the boot time of the app is <em>significantly longer</em> and the log is flooded with <code>Xlint:cantFindType</code> errors</p>
  
  <p>Example:</p>
  
  <pre><code>2016-11-07 19:28:21.944  INFO 45213 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  [AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.security.ldap.authentication.LdapAuthenticationProvider
  when weaving type org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer
  when weaving classes 
  when weaving 
   [Xlint:cantFindType]
  [AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type io.undertow.server.handlers.accesslog.AccessLogHandler
  when weaving type org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
  when weaving classes 
  when weaving 
   [Xlint:cantFindType]
  [AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type io.undertow.server.handlers.accesslog.AccessLogHandler
  when weaving type org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
  when weaving classes 
  when weaving 
   [Xlint:cantFindType]
  [AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type io.undertow.server.handlers.accesslog.AccessLogHandler
  when weaving type org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
  when weaving classes 
  when weaving 
   [Xlint:cantFindType]
  .. many more.. all in the org.springframework.boot package
  </code></pre>
  
  <h2>When running a test via gradle command line -> works, sort of.</h2>
  
  <p><del>When I run the test with <code>gradle test --tests *MyTestClass</code>, the test fails because of a NullPointerException on.. guess what, the <code>@Autowired</code> bean I'm expecting to be injected automatically.</del></p>
  
  <p>I got it working with gradle test config, huzzah! I've updated the configuration above. But.. it suffers from the same problem as running it in my IDE: <code>the Xlint:cantFindType</code></p>
  
  <hr>
  
  <p>So the issues:</p>
  
  <ol>
  <li><p><del> The gradle configuration is wrong, so running the app via gradle fails. How do I fix the gradle config?</del></p></li>
  <li><p>The <code>Xlint:cantFindType</code> errors. Is the aop.xml not being picked up? <strong>How to resolve this?</strong></p></li>
  </ol>
  
  <p>I have yet to find a simple spring-boot+gradle+ @Configurable sample that uses aop.xml</p>