users@glassfish.java.net

Using AspectJ's LoadTimeWeaving with Glassfish v2.1

From: <glassfish_at_javadesktop.org>
Date: Mon, 15 Feb 2010 10:33:32 PST

Hi all,

I am posting here after all google searches and self-trials, which all failed me to provide me with some help. I am trying to bring some how the AspectJ's Load time weaving feature running in Glassfish V2.1.

I have installed the aspectjweaver.jar in GF/lib folder and set the following in the domain.xml
<jvm-options>-javaagent:${com.sun.aas.installRoot}/lib/aspectjweaver.jar</jvm-options>

When I start Glassfish, I get the following stack trace and after few more lines from AspectJWeaver after which I get nothing in my logs. I can understand the stack trace. ServerLogManager is loaded by the SharedChainClassloader and the aspectjweaver.jar is loaded by SharedChainClassloader's parent, the SystemClassloader. Aspectjweaver cannot and will not see a class that will be loaded by a child classloader.

I tried to circumvent this problem by settting the default LogManager to Log4J's LogManager but still no results.

any ideas ?

Could not load Logmanager "com.sun.enterprise.server.logging.ServerLogManager"
java.lang.ClassNotFoundException: com.sun.enterprise.server.logging.ServerLogManager
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.util.logging.LogManager$1.run(LogManager.java:166)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.<clinit>(LogManager.java:156)
        at java.util.logging.Logger.getLogger(Logger.java:274)
        at org.aspectj.weaver.tools.Jdk14Trace.<init>(Jdk14Trace.java:26)
        at org.aspectj.weaver.tools.Jdk14TraceFactory.getTrace(Jdk14TraceFactory.java:17)
        at org.aspectj.weaver.loadtime.Aj.<clinit>(Aj.java:45)
        at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.<clinit>(ClassPreProcessorAgentAdapter.java:32)
        at org.aspectj.weaver.loadtime.Agent.<clinit>(Agent.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
[Message sent by forum member 'balsmn' (balasubramanian.azhagappan_at_de.bosch.com)]

http://forums.java.net/jive/thread.jspa?messageID=386831