Hi

[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).
>

On one hand, the explanation makes sense as it seems (I do  not know the
app very well), that the Felix classloader is being used to load OSGi
plugins from a specific path (outside the app's WEB-INF/lib).  However, if
that is the case, how is it finding the aop.xml?  Or is that being
inherited from the parent classloader?  Otherwise, I fail to understand
how/why the Felix classloader would be able to find the aop.xml in the
classpath, but not the com.ia.UseProfiler aspect.

Does that felix classloader offer any extra configuration options?
>

I know very little about Felix, or how it is configured.  In fact, until I
saw thre error, I did not even know that Felix was being used.

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.
>

A valid point/option, but the app validates checksums of its jars before
running, so that would cause a warning and/or a failure.

Thanks,

Eric


> On 29 July 2013 11:07, Eric B <ebenza...@gmail.com> 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@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to