Community
Participate
Working Groups
I am trying to weave into Tomcat with a system-level aspect (META-INF/aop.xml is found in a jar on the system classpath), and also have a Web application with an aop.xml properly deployed. When I try to run them both together, only the system-level aspects work. If I remove the system-level aspect jar from the classpath, the application-level aspects work. What would be a reasonable way to isolate this into a test case? If I could package up a simple system.jar and app.war file for Tomcat 5.5.9, would that be useful for you to use in debugging it? I tried making a simple standalone version with 2 aop.xml files in the same app classloader but that works just fine.
tagging with M4...
I'm not quite sure I understand the problem: 1. When you say "weav into Tomcat" do you mean you are weaving Tomcat classes? 2. When you say "system classpath" do you you java.class.path or sun.boot.class.path 3. When you day "only the system-level aspects work" do you mean only the Tomcat classes are woven? 4. Could you send the aop.xml files? Are you explicity including/excluding classes or aspects? 5. Could you use weaver options "-verbose" and/or "-showWeavInfo" and append the resulting logs.
Hi Matthew, 1) I have added a jar to the CLASSPATH used on start-up of Tomcat (but not the bootclasspath). This jar includes a META-INF/aop.xml file. So the aspects in the jar will weave into everything loaded from the AppClassLoader down. 2) java.class.path 3) The jar in the CLASSPATH weaves properly into everything in the system. Debug information shows that both it and the Web application-level jar are being recognized for the Web app, but that only it is affecting the Web app. 4) Here are the aop.xml files below 5) I will post in a follow-up classpath agent's aop.xml <!-- FIXME fails when DTD here and call from Ant--> <!--<!DOCTYPE aspectj PUBLIC--> <!-- "-//AspectJ//DTD//EN"--> <!-- "http://www.aspectj.org/dtd/aspectj_1_5_0.dtd">--> <aspectj> <weaver options="-proceedOnError"> <!-- -showWeaveInfo -verbose --> <exclude within="com.crankj..*"/> <exclude within="org.eclipse..*"/> <exclude within="org.apache.struts.util..*"/> <exclude within="org.apache.catalina.core..*"/> <exclude within="org.apache.catalina.cluster..*"/> <exclude within="org.apache.commons..*"/> <exclude within="org.apache.xerces..*"/> <exclude within="org.apache.jasper..*"/> <exclude within="org.apache.tomcat.util..*"/> <exclude within="org.apache.catalina.util..*"/> <exclude within="edu.emory..*"/> <exclude within="org.apache.juli..*"/> <exclude within="org.apache.naming..*"/> <exclude within="org.apache.coyote..*"/> <exclude within="org.apache.catalina.storeconfig..*"/> <exclude within="org.apache.jk..*"/> <exclude within="org.apache.webapp..*"/> <exclude within="org.apache.log4j..*"/> <exclude within="org.springframework..*"/> <!-- <exclude within="*..*CGLIB$*"/> <exclude within="$Proxy**"/> <exclude within="sun.reflect.Generated*"/> <exclude within="com.sun.jmx..*"/> --> </weaver> <aspects> <!-- see here nested class with ".", "$" is accepted as well --> <aspect name="com.crankj.monitor.ui.ServletRequestMonitor"/> <aspect name="com.crankj.monitor.ui.StrutsRequestMonitor"/> <aspect name="com.crankj.monitor.resource.JdbcMonitor"/> <aspect name="com.crankj.config.CrankjSystemInitializer"/> </aspects> </aspectj> Web Application aop.xml file: <aspectj> <!-- <weaver options="-proceedOnError -showWeaveInfo -verbose"> --> <weaver options="-proceedOnError"> <exclude within="com.crankj..*"/> <exclude within="org.eclipse..*"/> <exclude within="org.apache.commons..*"/> <exclude within="org.apache.xerces..*"/> <exclude within="org.apache.naming..*"/> <exclude within="org.apache.catalina.storeconfig..*"/> <exclude within="org.apache.jk..*"/> <exclude within="org.apache.webapp..*"/> <exclude within="org.apache.log4j..*"/> <exclude within="org.springframework..*"/> </weaver> <aspects> <aspect name="com.crankj.aspects.BadSysInfluence"/> <aspect name="com.crankj.aspects.BadAppInfluence"/> </aspects> </aspectj>
You may be encountering a bug with class loaders that I have experienced under OSGi (now fixed). Like that environment I presume Tomcat defines it's own. The problem lies with ClassLoader.getResources() which the AspectJ weaving adaptor uses to find all the available aop.xml files; in your case 2. The bug is that it only finds the first one. You can confirm this using the lastest AspectJ 5 M3, which has lot's of new diagnostic messages, and use "- Daj.weaving.verbose=true".
I found that both the aop.xml files were being found, so the issue in my case occurred later...
Could you append the log (or at least the relevant parts)? Do you get weaving messages for the required classes (indicating they are being processed) but no weaveInfo messages (indicating there are no matches)? I assume the classes are not in com.crankj which is excluded or org.aspectj, java or javax which are also exluded automatically. Have you looked at stderr? If an exception occurs during weaving it will be caught in the adaptor and logged but class loading will continue.
Ron, can you update the status of this one? Does it still stands or?
This is still a bug. I just tried with a recent dev build (Oct. 21) and I see the same behavior: I have a simple trace aspect in my Web application that works with load-time weaving (it is compiled in but there's also an aop.xml file that is showing as weaving when I deploy just the app). When I add a jar with load-time weaving to the parent classloader's classpath (i.e., Tomcat's shared lib directory), the Web application's LTW aspect no longer has an affect. I cranked up verbose weave information and you can see that the weaver is loading the aop.xml definitions, but it is not applying the advice from the child classloaders' ... info using aspectpath: [] info zipfile classpath entry does not exist: C:\java\jrockit-jdk1.5.0_03 \jre\lib\i18n.jar info zipfile classpath entry does not exist: C:\java\jrockit-jdk1.5.0_03 \jre\lib\sunrsasign.jar info directory classpath entry does not exist: C:\java\jrockit-jdk1.5.0_03 \jre\classes info register classloader org.apache.jasper.servlet.JasperLoader@5075224 info using file:/C:/jakarta-tomcat-5.5.9/shared/lib/crankjAgent.jar!/META- INF/aop.xml info using /C:/jakarta-tomcat-5.5.9/webapps/jpetstore/WEB-INF/classes/META- INF/aop.xml
cannot reproduce see test AtAjLtwTests.testAppContainer() look for AppContainerTest.java in tests/ module see the sandbox to get an hint on how the rather complex test case works (simulates on container with 2 deployed apps, sharing same classname inside like compiled jsp can, with a global aspect, and one local aspect in only one of the deployed app)
just moved to P2 to make sure we close this out one way or another before RC1
Ron, can you provide a test case for that one ? I could not reproduce it.
Fixed in recent builds.