You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Dan Becker <da...@gmail.com> on 2009/07/13 17:26:45 UTC
Use of AspectJ load time weaving in Geronimo
I've been implementing an Aspect Oriented Programming (AOP) profiling
and timing system on some of my web application code. I've been able to
Load Time Weave (LTW) my application code using plain Apache Tomcat by
placing the following AOP configuration file in
WEB-INF/classes/META-INF/aop.xml:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN"
"http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-verbose -showWeaveInfo">
<!-- Weave classes in our application-specific packages -->
<include within="com.mycompany.myapp..*"/>
</weaver>
<aspects>
<aspect name="com.mycompany.myapp.PointcutDefs"/>
<aspect name="com.mycompany.myapp.ProfilingAspect"/>
</aspects>
</aspectj>
However, when I try the same operation in Geronimo 1.1.1 (J2EE version
with Tomcat), I do not see the weaver weaving, nor do I catch any of the
application code with the pointcuts or the aspects.
Have other people tried AOP with Geronimo? Have they been successful
load time weaving with such a configuration file? Pointers to any AOP
examples with Geronimo are appreciated.
--
Thanks, Dan
Re: Use of AspectJ load time weaving in Geronimo
Posted by Kevan Miller <ke...@gmail.com>.
On Jul 13, 2009, at 5:43 PM, Dan Becker wrote:
> Ahh, true Kevan, I am omitting one other step that I normally do to
> make this run on Apache Tomcat. Namely, this context.xml is placed
> in the web app META-INF/context.xml, and the Spring JAR spring-
> tomcat-weaver.jar is placed into $CATALINA_HOME/server/lib:
>
> <Context path="/MyApp" reloadable="false">
> <Loader
> loaderClass
> =
> "org
> .springframework
> .instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
> </Context>
Thanks.
>
> I've had success now in Geronimo with instrumenting the the system
> class loader by setting JAVA_OPTS==-javaagent:%ASPECTJ_WEAVER%
> (where ASPECTJ_WEAVER points to aspectjweaver-1.6.2.jar) before I
> call geronimo.bat, but I would rather run the weaver as part of the
> web app class loader rather than the system class loader. So is it
> possible to do an instrumented web app class classloader using
> context.xml or some other mechanism in Geronimo?
I don't see how. Not without some changes within Geronimo. Is it
important that this capability be restricted to only certain
application classloaders? And not all Geronimo classloaders (which is
what you get with javaagent)?
--kevan
Re: Use of AspectJ load time weaving in Geronimo
Posted by Dan Becker <da...@gmail.com>.
Ahh, true Kevan, I am omitting one other step that I normally do to make
this run on Apache Tomcat. Namely, this context.xml is placed in the web
app META-INF/context.xml, and the Spring JAR spring-tomcat-weaver.jar is
placed into $CATALINA_HOME/server/lib:
<Context path="/MyApp" reloadable="false">
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>
I've had success now in Geronimo with instrumenting the the system class
loader by setting JAVA_OPTS==-javaagent:%ASPECTJ_WEAVER% (where
ASPECTJ_WEAVER points to aspectjweaver-1.6.2.jar) before I call
geronimo.bat, but I would rather run the weaver as part of the web app
class loader rather than the system class loader. So is it possible to
do an instrumented web app class classloader using context.xml or some
other mechanism in Geronimo?
Kevan Miller wrote:
> On Jul 13, 2009, at 11:26 AM, Dan Becker wrote:
>
>> I've been implementing an Aspect Oriented Programming (AOP) profiling
>> and timing system on some of my web application code. I've been able
>> to Load Time Weave (LTW) my application code using plain Apache Tomcat
>> by placing the following AOP configuration file in
>> WEB-INF/classes/META-INF/aop.xml:
>> ...
>>
>> However, when I try the same operation in Geronimo 1.1.1 (J2EE version
>> with Tomcat), I do not see the weaver weaving, nor do I catch any of
>> the application code with the pointcuts or the aspects.
>
> I assume you're using G 1.1.1 for a reason. Have you tried 2.1.4?
>
> You must be doing more than simply creating an aop.xml file. Otherwise,
> how is AspectJ getting loaded/triggered to read the configuration file?
>
>>
>> Have other people tried AOP with Geronimo? Have they been successful
>> load time weaving with such a configuration file? Pointers to any AOP
>> examples with Geronimo are appreciated.
>
> Maybe others who have used it. I've never tried it. But interested to
> see it running. Even more interested to see it on G 2.1.4 :-P, but happy
> to help with 1.1.1, also...
>
> Prolly best to follow up on our user@ list...
>
--
Thanks, Dan
Re: Use of AspectJ load time weaving in Geronimo
Posted by Dan Becker <da...@gmail.com>.
Ahh, true Kevan, I am omitting one other step that I normally do to make
this run on Apache Tomcat. Namely, this context.xml is placed in the web
app META-INF/context.xml, and the Spring JAR spring-tomcat-weaver.jar is
placed into $CATALINA_HOME/server/lib:
<Context path="/MyApp" reloadable="false">
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>
I've had success now in Geronimo with instrumenting the the system class
loader by setting JAVA_OPTS==-javaagent:%ASPECTJ_WEAVER% (where
ASPECTJ_WEAVER points to aspectjweaver-1.6.2.jar) before I call
geronimo.bat, but I would rather run the weaver as part of the web app
class loader rather than the system class loader. So is it possible to
do an instrumented web app class classloader using context.xml or some
other mechanism in Geronimo?
Kevan Miller wrote:
> On Jul 13, 2009, at 11:26 AM, Dan Becker wrote:
>
>> I've been implementing an Aspect Oriented Programming (AOP) profiling
>> and timing system on some of my web application code. I've been able
>> to Load Time Weave (LTW) my application code using plain Apache Tomcat
>> by placing the following AOP configuration file in
>> WEB-INF/classes/META-INF/aop.xml:
>> ...
>>
>> However, when I try the same operation in Geronimo 1.1.1 (J2EE version
>> with Tomcat), I do not see the weaver weaving, nor do I catch any of
>> the application code with the pointcuts or the aspects.
>
> I assume you're using G 1.1.1 for a reason. Have you tried 2.1.4?
>
> You must be doing more than simply creating an aop.xml file. Otherwise,
> how is AspectJ getting loaded/triggered to read the configuration file?
>
>>
>> Have other people tried AOP with Geronimo? Have they been successful
>> load time weaving with such a configuration file? Pointers to any AOP
>> examples with Geronimo are appreciated.
>
> Maybe others who have used it. I've never tried it. But interested to
> see it running. Even more interested to see it on G 2.1.4 :-P, but happy
> to help with 1.1.1, also...
>
> Prolly best to follow up on our user@ list...
>
--
Thanks, Dan
Re: Use of AspectJ load time weaving in Geronimo
Posted by Kevan Miller <ke...@gmail.com>.
Hi Dan,
On Jul 13, 2009, at 11:26 AM, Dan Becker wrote:
> I've been implementing an Aspect Oriented Programming (AOP)
> profiling and timing system on some of my web application code. I've
> been able to Load Time Weave (LTW) my application code using plain
> Apache Tomcat by placing the following AOP configuration file in WEB-
> INF/classes/META-INF/aop.xml:
>
> <!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd
> ">
> <aspectj>
> <weaver options="-verbose -showWeaveInfo">
> <!-- Weave classes in our application-specific packages -->
> <include within="com.mycompany.myapp..*"/>
> </weaver>
>
> <aspects>
> <aspect name="com.mycompany.myapp.PointcutDefs"/>
> <aspect name="com.mycompany.myapp.ProfilingAspect"/>
> </aspects>
> </aspectj>
>
> However, when I try the same operation in Geronimo 1.1.1 (J2EE
> version with Tomcat), I do not see the weaver weaving, nor do I
> catch any of the application code with the pointcuts or the aspects.
I assume you're using G 1.1.1 for a reason. Have you tried 2.1.4?
You must be doing more than simply creating an aop.xml file.
Otherwise, how is AspectJ getting loaded/triggered to read the
configuration file?
>
> Have other people tried AOP with Geronimo? Have they been successful
> load time weaving with such a configuration file? Pointers to any
> AOP examples with Geronimo are appreciated.
Maybe others who have used it. I've never tried it. But interested to
see it running. Even more interested to see it on G 2.1.4 :-P, but
happy to help with 1.1.1, also...
Prolly best to follow up on our user@ list...
--kevan