I have an @AspectJ-style aspect that I have been using for logging in a Tomcat web application, using Spring AOP autoproxying to good effect. I have now run into a situation where I need to profile code whose source code I cannot control, and which is currently unsuitable (for a variety of reasons) to be managed by Spring.
After reading the documentation, it sounded like enabling full AspectJ LTW would be the answer to my problems. Unfortunately, this has proven to be an exercise in frustration thus far. As I know that I already have a working aspect with valid pointcuts, I am first attempting to migrate it from Spring AOP to AspectJ LTW before trying to add new pointcuts to non-Spring managed code. Thus far, my attempts have ended in abject failure.
- Add org.springframework.instrument.tomcat-3.0.2.RELEASE.jar to $CATALINA_HOME/lib.
- Addto my main web application context.Code:<context:load-time-weaver />
- Create a META-INF/aop.xml that contains the following (taken from Spring documentation):
Code:<?xml version="1.0" encoding="UTF-8"?> <aspectj> <aspects> <!-- weave in just this aspect --> <aspect name="com.mycompany.logging.LoggingAspect" /> </aspects> <weaver options="-debug -Xset:weaveJavaxPackages=true"> <!-- only weave classes in our application-specific packages --> <include within="com.mycompany..*" /> </weaver> </aspectj>
- Added the following line to context.xml:Code:<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false" />
The only evidence I have that the class loader is being picked up is the following message from Tomcat when it loads the web application context:
In order to try and debug this, I added -Xset:weaveJavaxPackages=true to my aop.xml, but I still receive the warning. My (perhaps erroneous?) assumption based on this is that my aop.xml is not being read. I have examined the expanded WAR directory within $CATALINA_HOME/webapps, and have found the aop.xml exactly where it should be, in META-INF. This is tough to debug because I have been unable to figure out how to get the tools involved to give me debugging output with which to move forward. Any suggestions or hints people have on how I can get more information out of this setup would be very much appreciated.[TomcatInstrumentableClassLoader@2c979e8b] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified