[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] using -javaagent (aj5)


My code:

> cat Hello.java
public class Hello {

  public static void main(String[]argv) {
> cat World.aj
aspect World {
  after(): call(* println(..)) && !within(World) {
> javac Hello.java -d codebin
> ajc World.aj -d aspectsbin
> export CLASSPATH=codebin:aspectsbin
> aj5 Hello

What is in your aop.xml?  Using the default -outxml created me an
aop-ajc.xml, but I renamed to aop.xml to match your naming. Contents
<aspect name="World"/>

I added
<weaver options="-verbose"/>
in the aspectj section and ran again:

bin\>aj5 Hello
[AppClassLoader@a39137] info AspectJ Weaver Version DEVELOPMENT built
on Friday Jun 6, 2008 at 20:26:15 GMT
[AppClassLoader@a39137] info register classloader
[AppClassLoader@a39137] info using configuration
[AppClassLoader@a39137] info register aspect World
[AppClassLoader@a39137] info processing reweavable type World: World.aj

I then removed the aspectsbin and did what you did:
> ajc -outjar aspects.jar World.aj
I created META-INF/aop.xml as above (without weaver options) then
merged it into the jar
> jar -uvf aspects.jar META-INF
> export CLASSPATH=aspects.jar:codebin
> aj5 Hello

Which step am I doing that is different to what you are doing?  From a
re-read of your email it sounds like you are not putting the right
directory onto the classpath, you need to put the base relative to
where META-INF/aop.xml can be found, not META-INF itself.  It is
usually easier just to have it in the jar and if you build :
  ajc -outxml -outjar aspects.jar World.aj
then it will put the default aop xml file you need directly in the jar file.


2008/6/9 Tyler DeWitt <tyler.dewitt@xxxxxxxxxxxx>:
> Hello all,
>     I am trying to implement a simple test aspect to use load time weaving.
> I have a simple java program (Hello.java) and a simple aspect (World.aj).  I
> used >>javac Hello.java to compile the java program to Hello.class.  I then
> used >>ajc World.aj -outjar World.jar to compile the aspect to World.jar.  I
> then created a folder called META-INF and in that folder I created aop.xml.
> I then added META-INF to my CLASSPATH variable.  I set ASPECTPATH to
> work_dir/World.jar.  If I type >>aj Hello the weaving takes place.  If I
> type  >>aj5 Hello the weaving does not take place.  I tried to write a bogus
> aop.xml file and nothing changed.  What am I doing wrong?  Does someone have
> step by step instructions for using aj5?  The documentation does not make
> sense to me on the AspectJ website.  Specifically, I need to understand the
> usage of the -javaagent (that is what aj5 does) because I will be using
> aspectJ on Tomcat and cannot run aj or aj5.
> Thanks so much!
> Tyler
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users