Note: this post is cross-posted on Cubeia.com.
I have a new article up, Debugging Class Loading with AOP, in which I briefly discuss how Aspect Oriented Programming (AOP) using AspectJ can be used to debug class loading, in particular in instances where a system have multiple class loaders.It does not cover how to use the load time weaver that comes with AspectJ. For you reference, this is roughly how to use it (for Java 5 or higher):
- Download AspectJ from the Eclipse site.
- Create a configuration file called “aop.xml” in a META-INF folder on the class path. For an example file, see below.
- Start your VM with: -javaagent:pathto/aspectjweaver.jar
Which is about it, the “aop.xml” file may look something like this for running the code in the article in a Tomcat 6 installation:
<code lost in blog system move>
Notice above that we include the base package of your application for weaving and the Catalina class loader packages. We’re doing this to limit the scope of the weaver, otherwise your debugging may take a bit too much time and resources.