Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW probem with Tomcat / Felix classloader

Hi,

This stuff:

[ModuleClassLoader@4e730222] info register classloader org.apache.felix.framework.ModuleImpl$ModuleClassLoader@4e730222
[ModuleClassLoader@4e730222] info using configuration file:/Library/Tomcat/apache-tomcat-6.0.35-jira/webapps/jira/WEB-INF/lib/ia-aspects-0.0.1-SNAPSHOT.jar!/META-INF/aop.xml
[ModuleClassLoader@4e730222] info register aspect com.ia.UseProfiler
Jul 29, 2013 1:48:25 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: register definition failed
java.lang.RuntimeException: Cannot register non aspect: com$ia$UseProfiler , com.ia.UseProfiler

implies that the com.ia.UseProfiler aspect couldn't be found. AspectJ isn't trying anything magic, it is using the classloader getResource()/getResourceAsStream() type operations to access the aop.xml and the class files (for the aspect). If the classloader in question is choosing to do some unusual delegation or enforcing some rules that affect visibility of the aspect classes through those methods, it can manifest like this.

Does that felix classloader offer any extra configuration options?

> I have no access to change/modify the code
Does that just mean you don't have the source? If you have access to the classes you could just binary weave the aspect into the jars before you start it (no source code for the app required):

ajc -inpath inputjar.jar UseProfiler.aj -outjar wovenjar.jar

This means you don't need any LTW and don't need to worry about funky classloaders.

cheers,
Andy


On 29 July 2013 11:07, Eric B <ebenzacar@xxxxxxxxx> wrote:
Hi,

I'm trying to wrap a LTW aspect around a third-party webapp to do some debugging/profiling.  I have no access to change/modify the code, but at least I was hoping to see where/why some things were happening.   The webapp is running under a Tomcat 6.0.35 server.

I tried to write up a small, very innocuous aspect (ie: just prints the name of the method that is being executed) and tested it out with a HelloWorld servlet/webapp .  Everything worked as expected. 

When I tried to use it with the third-party app, things seem to be working properly at first:
<catalina.out snip>
WebappClassLoader@1c23f1bb] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT
[WebappClassLoader@1c23f1bb] info register classloader org.apache.catalina.loader.WebappClassLoader@1c23f1bb
[WebappClassLoader@1c23f1bb] info using configuration file:/Library/Tomcat/apache-tomcat-6.0.35-jira/webapps/jira/WEB-INF/lib/ia-aspects-0.0.1-SNAPSHOT.jar!/META-INF/aop.xml
[WebappClassLoader@1c23f1bb] info register aspect com.ia.UseProfiler
....
[WebappClassLoader@1c23f1bb] weaveinfo Join point 'method-execution(int com.credo.linker.user.util.DefaultUserManager.getTotalUserCount())' in Type 'com.credo.linker.user.util.DefaultUserManager' (DefaultUserManager.java:81) advised by after advice from 'com.ia.UseProfiler' (UseProfiler.aj:20)
[WebappClassLoader@1c23f1bb] weaveinfo Join point 'method-execution(java.util.Collection com.credo.linker.user.util.DefaultUserManager.getUsers())' in Type 'com.credo.linker.user.util.DefaultUserManager' (DefaultUserManager.java:88) advised by after advice from 'com.ia.UseProfiler' (UseProfiler.aj:20)
</snip>


However, shortly after, I see the following show up in catalina.out:
[ModuleClassLoader@4e730222] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT
[ModuleClassLoader@4e730222] info register classloader org.apache.felix.framework.ModuleImpl$ModuleClassLoader@4e730222
[ModuleClassLoader@4e730222] info using configuration file:/Library/Tomcat/apache-tomcat-6.0.35-jira/webapps/jira/WEB-INF/lib/ia-aspects-0.0.1-SNAPSHOT.jar!/META-INF/aop.xml
[ModuleClassLoader@4e730222] info register aspect com.ia.UseProfiler
Jul 29, 2013 1:48:25 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: register definition failed
java.lang.RuntimeException: Cannot register non aspect: com$ia$UseProfiler , com.ia.UseProfiler
at org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect(BcelWeaver.java:221)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects(ClassLoaderWeavingAdaptor.java:478)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions(ClassLoaderWeavingAdaptor.java:303)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:170)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java:313)
at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(Aj.java:318)
at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java:292)
at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:103)
at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:54)
at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1829)
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:716)
at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:634)
at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3653)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1812)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1734)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1143)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:680)


I'm not entirely sure what is happening, but it appears that the webapp is loading its own classloader (Felix) for use in the application, and that the Felix classloader does not know how to register the aspects.

I am starting tomcat with -javaagent:/path/to/aspectjweaver-1.7.3.jar

Is this a class loader issue in which the Felix classloader does not have access to the aspectjweaver classes?
How do I get around the problem?

My aop.xml is pretty mundane as well:
<aspectj>
  <weaver options="-verbose -showWeaveInfo">
    <include within="com.credo.linker.user.*"/>
  </weaver>

  <aspects>
    <aspect name="com.ia. UseProfiler"/>
  </aspects>
</aspectj>


Thanks!

Eric

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top