Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ LTW problem with JMX

I found how to debug AspectJ java agent…

 

When I debug it, my java agent detect a classloader with the aop.xml, but the AspectJ agent is not activated for this classloader. How can that happen?? To see this, I have a breakpoint at the beginning of org.aspectj.weaver.loadtime.Aj.preProcess(String, byte[], ClassLoader, ProtectionDomain)

 

One thing a little more strange is that I found a “solution”: on the command line, I have to declare my agent after I declared the aspect agent… Does anyone can explain me how it can work?

 

Working “solution”:

"C:\Program Files\Java\jdk1.6.0_22\bin\java"

-javaagent:.\libs\aspectjweaver-1.7.3.jar

-cp ".\libs\ProtoApp-v0.0.1-SNAPSHOT.jar;.\libs\*" -Xms64m -Xmx512m -XX:MaxPermSize=128m

-Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true

-javaagent:.\org.iiter.continuum.protos.agent-0.0.1-SNAPSHOT.jar

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7777 -Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

-Dlogback.configurationFile=file:.\logback.xml org.iiter.continuum.protos.simple.App

 

Not working:

                "C:\Program Files\Java\jdk1.6.0_22\bin\java"

-javaagent:.\org.iiter.continuum.protos.agent-0.0.1-SNAPSHOT.jar

-javaagent:.\libs\aspectjweaver-1.7.3.jar

-cp ".\libs\ProtoApp-v0.0.1-SNAPSHOT.jar;.\libs\*" -Xms64m -Xmx512m -XX:MaxPermSize=128m

-Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7777 -Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

-Dlogback.configurationFile=file:.\logback.xml org.iiter.continuum.protos.simple.App

 

And it doesn’t work if I don’t add my own java agent…

 

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Tugdual JULLIEN
Envoyé : mardi 30 juillet 2013 09:45
À : aspectj-users@xxxxxxxxxxx
Objet : Re: [aspectj-users] AspectJ LTW problem with JMX

 

A small question to try to understand this problem : how can I debug the AspectJ agent with Eclipse?

I’m not very familiar with java agent debugging…

 

 

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Tugdual JULLIEN
Envoyé : jeudi 25 juillet 2013 12:55
À : aspectj-users@xxxxxxxxxxx
Objet : Re: [aspectj-users] AspectJ LTW problem with JMX

 

Thank you for your time Andy,

 

What I don’t understand (yet) is the mecanism used in AspectJ agent for selecting classloaders. It seems to ignore some classloaders, especially the one that contains the configuration.

I join my test projects (one for the application, one for the aspect and one for the agent), if I made a mistake in my use of AspectJ (or JMX).

I run it on Windows, and build it with maven 3., and the aspect jar is expected to be in the “libs” directory.

 

Tugdual

 

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Andy Clement
Envoyé : mercredi 24 juillet 2013 17:17
À : aspectj-users@xxxxxxxxxxx
Objet : Re: [aspectj-users] AspectJ LTW problem with JMX

 

I worried you would hit that next. We are really just delaying the problem by manually setting the configuration location.  The classloaders in the mix here don't want to play ball and are not enabling AspectJ to find the configuration or the aspects themselves via the regular means.

 

If I look at the description of NoCallStackClassLoader I see it is defined to do some 'funky stuff': http://www.cs.rit.edu/usr/local/pub/swm/jdoc6/javax/management/remote/rmi/NoCallStackClassLoader.html

and limits what can be seen through it.

 

AspectJ never creates classloaders of its own, just relying on those that already exist so things don't get overcomplicated.

 

I'm not sure what to suggest next - The NoCallStackClassLoader does offer constructor configuration options but I don't know if you can use system properties to configure it further. If I was debugging I'd see how that classloader is deciding to reject the lookups for the configuration and the the aspect classes.

 

Andy

 

 

On 23 July 2013 02:44, Tugdual JULLIEN <tugdual.jullien@xxxxxxxx> wrote:

Thanks Andy,

 

I tried this solution, but then I have a runtime error :

java.lang.RuntimeException: Cannot register non aspect: org$iiter$continuum$org$iiter$continuum$protos$aspects$Monitoring , org.iiter.continuum.org.iiter.continuum.protos.aspects.Monitoring

        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:632)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)

        at javax.management.remote.rmi.NoCallStackClassLoader.findClass(NoCallStackClassLoader.java:108)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

        at javax.management.remote.rmi.RMIConnector$1.run(RMIConnector.java:2065)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.management.remote.rmi.RMIConnector.<clinit>(RMIConnector.java:2086)

        at javax.management.remote.rmi.RMIConnectorServer.objectToBind(RMIConnectorServer.java:728)

        at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:392)

        at sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:716)

        at sun.management.jmxremote.ConnectorBootstrap.initialize(ConnectorBootstrap.java:396)

        at sun.management.Agent.startAgent(Agent.java:127)

        at sun.management.Agent.startAgent(Agent.java:239)

 

This is the same aop.xml that I use in my aspect jar. The only things I changed are:

-          Activation of JMX remote

-          Copy the aop.xml in my app directory

-          Add the parameter to the commande line

The commande line is:

"C:\Program Files\Java\jdk1.6.0_22\bin\java"

-javaagent:.\libs\aspectjweaver-1.7.3.jar

-cp ".\libs\ProtoApp-v0.0.1-SNAPSHOT.jar;.\libs\*"

-Xms64m -Xmx512m -XX:MaxPermSize=128m

-Daj.weaving.verbose=true

-Dorg.aspectj.weaver.showWeaveInfo=true

-Dorg.aspectj.weaver.loadtime.configuration=file:./aop.xml

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.port=7777

-Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

-Dlogback.configurationFile=file:.\logback.xml

org.iiter.continuum.protos.simple.App

 

The aspect jar is in my classpath (in the libs directory).

 

I tried to specify the aspect path with these options:

-Daj.class.path=.\libs

-Daj.aspect.path=.\libs\org.iiter.continuum.protos.aspects-0.0.1-SNAPSHOT.jar

 

But it doesn’t work…

Any hint for this ? (I hope I’m missing something)

 

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Andy Clement
Envoyé : mardi 23 juillet 2013 00:33
À : aspectj-users@xxxxxxxxxxx
Objet : Re: [aspectj-users] AspectJ LTW problem with JMX

 

It seems that the classloader are different: sun.misc.Launcher$AppClassLoader without JMX, javax.management.remote.rmi.NoCallStackClassLoader with JMX. Could it be the cause?

 

This is very likely the cause.  Typically AspectJ will look for the aop.xml via a getResources("META-INF/aop.xml") call on the classloader. If the classloader doesn't implement getResources in a good way, the file won't be found. As an alternative (as I look at the AJ source code) you might be able to specify a file path for it:

 

-Dorg.aspectj.weaver.loadtime.configuration=file:/path/to/my/aop.xml

 

cheers,

Andy

 

On 22 July 2013 03:21, Tugdual JULLIEN <tugdual.jullien@xxxxxxxx> wrote:

Hello,

 

I tried to do a simple project (hello world) with a simple aspect. I use Maven to build this project, LTW for the aspect, logback for the logs.

The aspect is weaved when I use:

"C:\Program Files\Java\jdk1.6.0_22\bin\java" -javaagent:.\libs\aspectjweaver-1.7.3.jar -cp ".\libs\ProtoApp-v0.0.1-SNAPSHOT.jar;.\libs\*" -Xms64m -Xmx512m -XX:MaxPermSize=128m -Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -Dlogback.configurationFile=file:.\logback.xml org.iiter.continuum.protos.simple.App

 

But when I add parameters for JMX, the aspect is not weaved anymore:

"C:\Program Files\Java\jdk1.6.0_22\bin\java" -javaagent:.\libs\aspectjweaver-1.7.3.jar -cp ".\libs\ProtoApp-v0.0.1-SNAPSHOT.jar;.\libs\*" -Xms64m -Xmx512m -XX:MaxPermSize=128m -Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7777 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlogback.configurationFile=file:.\logback.xml org.iiter.continuum.protos.simple.App

 

I can’t figure what’s happening, if any of you could help me.

 

The options for JMX remote I added are:

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.port=7777

-Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

 

Tugdual

 

PS: I tried for an OSGI app (equinox) and it works fine with this parameters for JMX, but I really need for a regular Java application.

 

PPS : I posted my question in stackoverflow: http://stackoverflow.com/questions/17784939/aspectj-ltw-not-working-with-jmx-remote

 

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Tugdual JULLIEN
Envoyé : lundi 15 juillet 2013 15:49
À : aspectj-users@xxxxxxxxxxx
Objet : [aspectj-users] AspectJ LTW problem with JMX

 

Hello everybody,

 

When I start my application (console) with the weaver agent, without JMX, everything is fine, with JMX the aspect configuration is not found. I use Aspectj 1.7.3 (I tried version 1.7.0 and 1.7.1).

The aspect configuration is done by the file META-INF/aop.xml which contains the weaver options:

-Xlint:ignore -Xset:weaveJavaPackages=false,weaveJavaxPackages=false

 

I searched and tried several solutions:

-          The aop.xml is not in the right place: moving the aop.xml in the sources in META-INF, generating with -outxml

-          The aspect configuration name: renaming aop.xml to aop-ajc.xml

-          There is classloader problems: I added the option -Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader

-          AspectJ can’t find the jar with aspect: I added the options "-Daj.class.path=.\libs\*" "-Daj.aspect.path=.\libs\org.iiter.aspects.monitoring-0.0.1-SNAPSHOT.jar"

The problem is still here…

 

It seems that the classloader are different: sun.misc.Launcher$AppClassLoader without JMX, javax.management.remote.rmi.NoCallStackClassLoader with JMX. Could it be the cause?

 

My projects are built with Maven. For the aspect, I use this plugin:

                    <plugin>

                           <groupId>org.codehaus.mojo</groupId>

                           <artifactId>aspectj-maven-plugin</artifactId>

                           <version>${aspectj.plugin.version}</version>

                           <configuration>

                                  <complianceLevel>${maven.compiler.source}</complianceLevel>

                                  <source>${maven.compiler.source}</source>

                                  <target>${maven.compiler.target}</target>

                           </configuration>

                           <executions>

                                  <execution>

                                        <goals>

                                               <goal>compile</goal>

                                               <goal>test-compile</goal>

                                        </goals>

                                  </execution>

                           </executions>

                           <dependencies>

                                  <!-- Ensure aspectj tools version used by compiler is the same version used as dependency. Avoids warning -->

                                  <dependency>

                                        <groupId>org.aspectj</groupId>

                                        <artifactId>aspectjtools</artifactId>

                                        <version>${aspectj.rt.version}</version>

                                  </dependency>

                           </dependencies>

                    </plugin>

 

 

All my jars (aspect, application and frameworks like slf4j and Spring) are in a “libs” directory.

 

When I start my application without JMX:

java

-javaagent:.\libs\aspectjweaver-1.7.3.jar

-cp ".\libs\application.jar;.\libs\*"

-Xms64m -Xmx512m -XX:MaxPermSize=128m

-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader

-Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true

"-Daj.class.path=.\libs\*"

"-Daj.aspect.path=.\libs\org.iiter.aspects.monitoring-0.0.1-SNAPSHOT.jar"

-Dlogback.configurationFile=file:.\logback.xml

org.iiter.application.Launcher

 

I get this logs:

[AppClassLoader@64601bb1] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT

[AppClassLoader@64601bb1] info register classloader sun.misc.Launcher$AppClassLoader@64601bb1

[AppClassLoader@64601bb1] info using configuration file:/C:/ compiled/application/libs/org.iiter.aspects.monitoring-0.0.1-SNAPSHOT.jar!/META-INF/aop.xml

[AppClassLoader@64601bb1] info register aspect org.iiter.aspects.monitoring.ContainerMonitoring

[AppClassLoader@64601bb1] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified

[AppClassLoader@64601bb1] weaveinfo Join point 'method-execution(void org.iiter.application.ContainerManager.start())' in Type 'org.iiter.application.ContainerManager' (ContainerManager.java:78) advised by before advice from 'org.iiter.aspects.monitoring.ContainerMonitoring' (ContainerMonitoring.aj:23)

[AppClassLoader@64601bb1] weaveinfo Join point 'method-execution(void org.iiter.continuum.cdc.commons.ContainerManager.start())' in Type 'org.iiter.continuum.cdc.commons.ContainerManager' (ContainerManager.java:78) advised by after advice from 'org.iiter.aspects.monitoring.ContainerMonitoring' (ContainerMonitoring.aj:28)

[AppClassLoader@64601bb1] weaveinfo Join point 'method-execution(void org.iiter.continuum.cdc.commons.ContainerManager.stop())' in Type 'org.iiter.continuum.cdc.commons.ContainerManager' (ContainerManager.java:109) advised by before advice from 'org.iiter.aspects.monitoring.ContainerMonitoring' (ContainerMonitoring.aj:33)

[AppClassLoader@64601bb1] info processing reweavable type org.iiter.aspects.monitoring.ContainerMonitoring: org\iiter\ aspects\monitoring\ContainerMonitoring.aj

[ExtClassLoader@61ba34f2] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT

[ExtClassLoader@61ba34f2] info register classloader sun.misc.Launcher$ExtClassLoader@61ba34f2

[ExtClassLoader@61ba34f2] info no configuration found. Disabling weaver for class loader sun.misc.Launcher$ExtClassLoader@61ba34f2

 

 

When I start my application with JMX:

java

-javaagent:.\libs\aspectjweaver-1.7.3.jar

-cp ".\libs\application.jar;.\libs\*"

-Xms64m -Xmx512m -XX:MaxPermSize=128m

-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader

-Daj.weaving.verbose=true

-Dorg.aspectj.weaver.showWeaveInfo=true

"-Daj.class.path=.\libs\*"

"-Daj.aspect.path=.\libs\org.iiter.aspects.monitoring-0.0.1-SNAPSHOT.jar"

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7777 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

-Dlogback.configurationFile=file:.\logback.xml

org.iiter.application.Launcher

 

I get this logs:

[NoCallStackClassLoader@97d01f] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT

[NoCallStackClassLoader@97d01f] info register classloader javax.management.remote.rmi.NoCallStackClassLoader@97d01f

[NoCallStackClassLoader@97d01f] info no configuration found. Disabling weaver for class loader javax.management.remote.rmi.NoCallStackClassLoader@97d01f

[NoCallStackClassLoader@7471dc3d] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT

[NoCallStackClassLoader@7471dc3d] info register classloader javax.management.remote.rmi.NoCallStackClassLoader@7471dc3d

[NoCallStackClassLoader@7471dc3d] info no configuration found. Disabling weaver for class loader javax.management.remote.rmi.NoCallStackClassLoader@7471dc3d

[ExtClassLoader@61ba34f2] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT

[ExtClassLoader@61ba34f2] info register classloader sun.misc.Launcher$ExtClassLoader@61ba34f2

[ExtClassLoader@61ba34f2] info no configuration found. Disabling weaver for class loader sun.misc.Launcher$ExtClassLoader@61ba34f2


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

 


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

 


Back to the top