I created an aspect/tomcat project using the aspectj Eclipse plugin for Eclipse. I ran the code stand-alone and it prints a message to the console which verifies it works. Next, I ran a servlet in Tomcat5.5.27 (with jdk1.6.0_10) that the aspect should interact with. I see no output in the console from the aspect (however, a lone System.out.println() works which shows me the output is not directed to the log file). Does anyone know of a web site that has step by step instructions on exactly how to set up aspectJ for Tomcat? I've been to a lot of web sites where the instructions are incomplete such as:
http://static.springsource.org/spring/docs/2.5.x/reference/orm.html#orm-jpa-setup-lcemfb-tomcat
Here is what I have so far
(it doesnt work, says "java.lang.NoClassDefFoundError: org/apache/catalina/loader/WebappClassLoader").
It uses Spring's jar files:
Deployment on Tomcat:
* Add this to c:/Program Files/Tomcat/Tomcat5.5.27/conf/Catalina/localhost/MyProject.xml (just below the opening <Context> tag):
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
<context:load-time-weaver />
* Add these to c:\Program Files\Tomcat\Tomcat5.5.27\common\lib:
aspectjrt.jar
aspectjtools.jar
aspectjweaver.jar
org.aspectj.matcher
spring-tomcat-weaver.jar
spring-agent.jar
* Add this to catalina.bat, (added at a specific location in the file):
set JAVA_OPTS=%JAVA_OPTS% -javaagent:C:\Program Files\Tomcat\Tomcat5.5.27\common\lib\spring-agent.jar -Xms64m -Xmx200m
* Add a new file called aop-ajc.xml to the project's WEB-INF/lib folder with this content:
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<include within="com.*"/>
</weaver>
<aspects>
<aspect name="com.myCompany.myProject.aj.PreparedStatementAspect"/>
</aspects>
</aspectj>