Integration with tomcat
mphansen Feb 9, 2005 3:37 PMHi,
I'm trying to use jboss-aop 1.1 with tomcat 4.0.29 and jdk 1.4.2.
I would like to use loadtime instrumentation. However, I'm not successful.
I use the following code:
<aop> <bind pointcut="execution(public void com.mycompany.mypackage.MyClass>myMethod(..))"> <interceptor class="com.mycompany.myutils.MethodInterceptor"/> </bind> </aop>
package com.mycompany.myutils; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.joinpoint.MethodInvocation; public class MethodInterceptor implements Interceptor { public String getName() { return MethodInterceptor.class.getName(); } public Object invoke(Invocation invocation) throws Throwable { try { MethodInvocation mi = (MethodInvocation)invocation; System.out.println("<<< Entering MethodInterceptor for: " + mi.getMethod().toString()); return invocation.invokeNext(); } finally { System.out.println(">>> Leaving MethodInterceptor"); } } }
I package the java class in myaspects.jar and put in CATALINA_HOME together with jboss-aop.xml. I modify catalina.sh to the following:
JBOSS_AOP_HOME="/home/me/bin/jboss-aop_1.1" JBOSS_AOP_LIBS="$JBOSS_AOP_HOME/lib/javassist.jar:\ $JBOSS_AOP_HOME/ib/trove.jar:$JBOSS_AOP_HOME/lib/concurrent.jar:\ $JBOSS_AOP_HOME/lib/jboss-common.jar:$JBOSS_AOP_HOME/lib/jboss-aop.jar" JAVA_OPTS="$JAVA_OPTS -Djboss.aop.path=$CATALINA_HOME/jboss-aop.xml -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader" CLASSPATH="$CLASSPATH:${JBOSS_AOP_LIBS}:$CATALINA_HOME/myaspects.jar" "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
My problem is that nothing happens. Nothing is written to the logs as should be done my MethodInterceptor.
Apparently something is working. For example, if a change the pointcut expression in jboss-aop.xml to be unparsable then the system complains about it (an exception is thrown about parse error in catalina.log).
Has anyone any suggestions to what I'm doing wrong? Is loadtime instrumentation supported with tomcat? Any help would be appreciated.