title: Tomcat 8, Spring Boot, @Configurable LoadTimeWeaving without -javaagent?
body: <p>I'm trying to setup a <code>@Configurable</code> domain object(not managed by the spring container).<br>
  I've got this working by adding the <code>-javaagent:path/to/spring-instrument.jar</code> as a JVM argument but it's not 100% clear to me whether or not this -javaagent MUST be in place. I'm running this on Tomcat 8. I may be misinterpreting the <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#aop-aj-ltw-environments">documentation</a> but it seems I may be able to use a another mechanism to accomplish this, in particular this line:</p>
  
  <blockquote>
    <p>Do not define <code>TomcatInstrumentableClassLoader</code> anymore on <code>Tomcat 8.0</code> and higher. Instead, let Spring automatically use Tomcat’s new native <code>InstrumentableClassLoader</code> facility through the <code>TomcatLoadTimeWeaver</code> strategy.</p>
  </blockquote>
  
  <p>Code Samples below:</p>
  
  <pre><code>@SpringBootApplication
  @EnableLoadTimeWeaving
  public class TestApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(TestApplication.class, args);
      }   
      @Bean
      public MyService myService(){
          return new MyService();
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>@Configurable
  public class MyDomainObject {
  
      @Autowired
      private MyService myService;
  
      public MyService getMyService(){
          return myService;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code> public class MyService {
      private static final Logger log = LoggerFactory.getLogger(MyService.class);
  
      public void test(){
          log.info("test");
      }
  }
  </code></pre>
  
  <p>So is there a way to get these @Configrable objects woven without specifying the -javaagent?  I'd be interested in learning if I can accomplish this when deploying as WAR to a Standalone Tomcat 8 server and/or using the embedded Tomcat 8 server when launching as a 'fat' jar.</p>
  
  <p>As it stands deploying to Stand alone Tomcat 8 server doesn't throw an error but the <code>getMyService()</code> method above returns null.  Launching as a fat jar throws the following error during startup:</p>
  
  <p><code>Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar</code></p>
  
  <p>I suppose the real question is how do I <code>Specify a custom LoadTimeWeaver</code> in Tomcat 8?  Nothing seems to be automatically happening as the documentation states but again I may be misinterpreting what that means exactly.</p>