title: Apache Tomcat 8 spring load time weaving is not working for beans loaded by ContextLoaderListener
body: <p>The issue happened while migrating from tomcat 7 java 7 to tomcat 8 java 8.</p>
  
  <p>In Tomcat 7 load time weaving was working based on loader class specified in the context.xml file </p>
  
  <pre><code>&lt;Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/&gt; 
  </code></pre>
  
  <p>As part of migration we removed the above loader class definition from the context.xml and deployed the application to tomcat8.</p>
  
  <p>Now load time weaving is only working for beans loaded by dispatcher servlet
  and the <strong>beans in applicationContext.xml  loaded by ContextLoaderListener is not working</strong>? Please provide any suggestions.</p>
  
  <p><em>Repeating the same question once more..</em></p>
  
  <p>How to prevent the beans in applicationContext.xml <strong>loading before starting load time weaving</strong> ?</p>
  
  <p>Am trying to configure the load time weaver without -javaagent options <strong>is it possible</strong> ?</p>
  
  <p><strong>Please note the important part of configurations given below</strong></p>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;aop:aspectj-autoproxy /&gt;
      &lt;context:spring-configured /&gt;
      &lt;context:load-time-weaver aspectj-weaving="autodetect"/&gt;     
      &lt;tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/&gt;
  
      &lt;bean id="mainContextLoadingService"
            class="com.riyaskt.trial.service.impl.MainContextLoadingServiceImpl" /&gt;  
  </code></pre>
  
  <p><strong>dispatcher-servlet.xml</strong></p>
  
  <pre><code>&lt;context:component-scan base-package="com.riyaskt.trial" /&gt;  
      &lt;mvc:annotation-driven/&gt;
  &lt;bean id="sampleService"
            class="com.riyaskt.trial.service.impl.SampleServiceImpl"          
            p:dao-ref="sampleDao"/&gt; 
  </code></pre>
  
  <p>In these two service beans (ie <strong>mainContextLoadingService</strong> in applicationContext.xml and  <strong>sampleService</strong> from <strong>dispatcher servlet</strong>) .</p>
  
  <p>sampleService is weaved properly </p>
  
  <p>but </p>
  
  <p>mainContextLoadingService <strong>is not weaved</strong> by load time weaver..</p>