title: How to configure load-time weaving with AspectJ and Tomcat?
body: <p>I tried to configure load-time weaving (for doing profiling with Perf4J) in the next way:</p>
  
  <p>1) I added <code>aop.xml</code> to <code>META-INF</code> folder. When deployed, META-INF is placed in the artifact root directory (i.e. <code>MyAppDeployed/META-INF</code>).</p>
  
  <p>2) I put <code>aspectjrt-1.6.1.jar</code>, <code>aspectjweaver-1.6.1.jar</code>, <code>commons-jexl-1.1.jar</code>, <code>commons-logging.jar</code> to the <code>Tomcat/lib</code> folder (at first I tried <code>MyAppDeployed/WEB-INF/libs</code> but it also didn't work).</p>
  
  <p>3) I added <code>-javaagent:C:\apache-tomcat-6.0.33\lib\aspectjweaver-1.6.1.jar</code> to VM options when starting Tomcat.</p>
  
  <p>4) My <code>aop.xml</code>:</p>
  
  <pre><code>&lt;!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"&gt;
  
  &lt;aspectj&gt;
  
      &lt;aspects&gt;
          &lt;aspect name="org.perf4j.log4j.aop.TimingAspect"/&gt;
      &lt;/aspects&gt;
  
      &lt;weaver options="-verbose -showWeaveInfo"&gt;           
          &lt;include within="com.mypackages.MyClass"/&gt;
      &lt;/weaver&gt;
  &lt;/aspectj&gt;
  </code></pre>
  
  <p>I don't see any signs that load-time weaving happens. Neither error-reports nor necessary results. The only error message I have is:</p>
  
  <pre><code>Error occurred during initialization of VM
  agent library failed to init: instrument
  Error opening zip file: C:\apache-tomcat-6.0.33\lib\wrong-jar.jar
  </code></pre>
  
  <p>in a case when I do a mistake in a <code>aspectjweaver-1.6.1.jar</code> name when specify a javaagent parameter. If it's written correctly - no error messages are printed. </p>
  
  <p>Any ideas, what am I doing wrong?</p>
  
  <p>P.S. I use Java 5, and I tried the same things with <code>1.5.4</code> version of the aspectj with exactly the same results.</p>