Re: [aspectj-users] newbie needs help configuring
• From: Alexandre Vasseur <avasseur@xxxxxxxxx>
• Date: Mon, 17 Oct 2005 09:59:56 +0200
• Delivered-to: aspectj-users@eclipse.org
• Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=iWsDb72UoU3Rc/sN4XLzlRaGE9AJyCqaE3W21AQxg4rz2xE78VH5E1RTLCbb9JxI4CeVVjn5hUptWUX6X15kkcyrOg5sj6QRtZYj95SA3JOpTHiIlI88F0eJyGKut3AZWE6ZdAGNDU6YAaSEiHZZinvSOtXZ8x3RKzT4sLXjYz4=

Actually the best way would be if you could file a bug and attach to
it a zip with ant script and source to reproduce it - if you manage to
reproduce it outside tomcat that 's even better.
You can attach the compiled aspect as well.
Alex

On 10/14/05, Andy Kriger <andy.kriger@xxxxxxxxx> wrote:
> In the webapp I have the aspectj jar files (all of them) in
> /usr/local/tomcat/shared/lib and I have the -javaagent switch set in
> catalina.sh to point to that dir. The webapp does not have aspectj jar
> files in WEB-INF/lib since they are loaded from shared/lib.
>
> However, I don't think the Tomcat/Axis environment has anything to do
> with this since I cannot get LTW to work outside the webapp either. I
> also tried with M3a and that didn't work either.
>
> Here are the details of my environment and how I'm running the test...
>
> * all the AspectJ jars are in a lib dir
> * my test calls a method in the weave target class
> * I have META-INF/aop.xml in my classes dir (same as in my original message)
> * I have the Aspect class in my classes dir (same as in my original message)
> * I have the class being woven in my class dir
> * I run the test using an Ant script - the script uses a classpath
> which has the AJ jars and the classes dir
> * I get a bunch of logging when I run...
>     [junit] info weaving 'com/capitalprinting/webservices/AOPTest'
>     [junit] info weaver operating in reweavable mode.  Need to verify
> any required types exist.
>     [junit] warning at com/myco/MyAspect.java::0 advice defined in
> com.myco/MyAspect has not been applied Xlint:adviceDidNotMatch]
>     [junit] info weaving 'com/myco/Services'
>     [junit] info weaver operating in reweavable mode.  Need to verify
> any required types exist.
>     [junit] weaveinfo Join point 'method-execution(java.lang.String[]
> com.myco.Services.getPrinterNames())' in Type 'com.myco.Services'
> (CapitalServices.java:54) advised by after advice from
> 'com.myco.MyAspect' (MyAspect.java)
> [rest of the weaveinfo Joint points deleted for brevity]
> [junit] java.lang.NoSuchMethodError:
> com.myco.MyAspect.aspectOf()Lcom/myco/MyAspect;
>
> Is that initial warning something to be concerned about or is that
> part of the normal weaving process (first the weaving isn't applied
> then it is)?
>
> Would it help you to have the bytecode so you can see what the
> compiled aspect looks like? Which files would you need - the Aspect
> and the Weave target or just the Aspect?
>
> Any other advice for narrowing it down? I do have it working with ajc
> but I'd like to help you solve the problem if I can.
>
> Thank you again,
> Andy
>
> On 10/14/05, Alexandre Vasseur <avasseur@xxxxxxxxx> wrote:
> > Here are the details:
> >
> > Given an @Aspect aspect, as you can see in your own code there is no
> > aspectOf() method (as there are implicit ones in the non @Aspect
> > aspectj syntax). This method is wether
> > - injected into the compiled aspect if you compile this one with ajc
> > - injected into the javac compiled aspect during load time weaving
> > In both case all that is transparent to you.
> >
> >
> > so it looks like you have hit some issue with the second option as
> > switching to the 1st one shows that your configuration and aspect is
> > valid.
> > I would appreciate if you could describe where you package the javac
> > compile aspect (alongside the webapp or in some other level like fe.
> > tomcat shared classes) or if you could try to narrow down the issue
> > outside of a tomcat.
> >
> > Alex
> >
> > On 10/14/05, Andy Kriger <andy.kriger@xxxxxxxxx> wrote:
> > > And finally, I used ajc to compile my source and run the same test and
> > > it worked. So maybe a combination of Annotations and load-time weaving
> > > is causing the problem?
> > >
> > > On 10/14/05, Andy Kriger <andy.kriger@xxxxxxxxx> wrote:
> > > > When I try the call outside the web application, I get this error...
> > > >  [junit] Testcase: testAOP(com.myco.AOPTest): Caused an ERROR
> > > >  [junit] com.myco.MyAspect.aspectOf()Lcom/myco/MyAspect;
> > > >  [junit] java.lang.NoSuchMethodError:
> > > > com.myco.MyAspect.aspectOf()Lcom/myco/MyAspect;
> > > >
> > > > That looks pretty significant - any idea what it means? Have I missed
> > > > something in implementing my Aspect or the way I'm using the
> > > > Annotations?
> > > >
> > > > On 10/14/05, Andy Kriger <andy.kriger@xxxxxxxxx> wrote:
> > > > > 1. Yep, using Java 5
> > > > > 2. Haven't tried static weaving or logging outside the webapp/SOAP
> > > > > call - I'll try those and post a followup.
> > > > > 3. Here's what I see in the LTW log...
> > > > > info weaving 'com/myco/Service'
> > > > > info weaver operating in reweavable mode.  Need to verify any required
> > > > > types exist.
> > > > > weaveinfo Join point 'method-execution(boolean
> > > > > com.myco.Service.isXml(java.lang.String))' in Type 'com.myco.Service'
> > > > > (Service.java:2469) advised by after advice from 'com.myco.MyAspect'
> > > > > (MyAspect.java)
> > > > > weaveinfo Join point 'method-execution(java.lang.String
> > > > > com.myco.Service.generateXML(java.lang.String))' in Type
> > > > > 'com.myco.Service' (Service.java:2474) advised by after advice from
> > > > > 'com.myco.MyAspect' (MyAspect.java)
> > > > > etc etc etc for all the methods in Service
> > > > >
> > > > > I never see it reach a point where AspectJ logs a message about a
> > > > > Service method call or " info weaving 'com/myco/MyAspect' ".
> > > > >
> > > > > Thanks for the help,
> > > > > Andy
> > > > >
> > > > > On 10/14/05, Matthew Webster <matthew_webster@xxxxxxxxxx> wrote:
> > > > > >
> > > > > > Andy,
> > > > > >
> > > > > > Hopefully these questions won't seem too silly:
> > > > > > 1. The @AspectJ syntax requires Java 5 so I assume you are using that to run
> > > > > > AXIS?
> > > > > > 2. Have you tried static weaving your application and testing it either
> > > > > > outside (JUnit) or inside AXIS that way?
> > > > > > 3. Could you post the LTW log or a least the interesting part of it?
> > > > > >
> > > > > > I have successfylly tried you testcase with my own simple Service class:
> > > > > >
> > > > > >
> > > > > > info weaving 'com/myco/Service'
> > > > > > info weaver operating in reweavable mode.  Need to verify any required types
> > > > > > exist.
> > > > > > weaveinfo Join point 'method-execution(void
> > > > > > com.myco.Service.main(java.lang.String[]))' in Type 'com.myco.Service'
> > > > > > (Service.java:6) advised by after advice from 'com.myco.MyAspect'
> > > > > > (MyAspect.java)
> > > > > > Service.main()
> > > > > > info weaving 'com/myco/MyAspect'
> > > > > > info weaver operating in reweavable mode.  Need to verify any required types
> > > > > > exist.
> > > > > > info processing reweavable type com.myco.MyAspect: com\myco\MyAspect.java
> > > > > > info successfully verified type com.myco.MyAspect exists.  Originates from
> > > > > > com\myco\MyAspect.java
> > > > > > Aspect logXyPath was called
> > > > > >
> > > > > > Cheers
> > > > > >
> > > > > > Matthew Webster
> > > > > >  AOSD Project
> > > > > >  Java Technology Centre, MP146
> > > > > >  IBM Hursley Park, Winchester,  SO21 2JN, England
> > > > > >  Telephone: +44 196 2816139 (external) 246139 (internal)
> > > > > >  Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
> > > > > > http://w3.hursley.ibm.com/~websterm/
> > > > > >
> > > > > > Please respond to aspectj-users@xxxxxxxxxxx
> > > > > >
> > > > > > Sent by:        aspectj-users-bounces@xxxxxxxxxxx
> > > > > >
> > > > > > To:        aspectj-users@xxxxxxxxxxx
> > > > > > cc:
> > > > > > Subject:        Re: [aspectj-users] newbie needs help configuring
> > > > > >
> > > > > >
> > > > > > The stack trace isn't really meaningful since the only trace I see is
> > > > > >  an Axis SOAP Fault that wraps (and masks) the exception being thrown
> > > > > >  from within the web application. I cannot see where the trace
> > > > > >  originates only really the InvocationTargetException. There's nothing
> > > > > >  in the logs that indicates what problem, if any, AspectJ is having. I
> > > > > >  already have the verbose switch in the aop.xml. If there's a way to
> > > > > >  turn on more logging, please let me know.
> > > > > >
> > > > > >  On 10/13/05, Alexandru Popescu
> > > > > > <the.mindstorm.mailinglist@xxxxxxxxx> wrote:
> > > > > >  > #: Andy Kriger changed the world a bit at a time by saying on  10/13/2005
> > > > > > 11:06 PM :#
> > > > > >  > > I am trying to use load-time weaving in AspectJ 1.5M4 to log our web
> > > > > >  > > service running on Axis 1.2 in Tomcat 5.8. Right now I'm trying to get
> > > > > >  > > a very simple proof-of-concept working. I make calls to web service
> > > > > >  > > methods expecting to see logging to stdout and instead I keep running
> > > > > >  > > into InvocationTargetExceptions. I've included my config below.
> > > > > >  > >
> > > > > >  > > If I comment out the Advice part of MyAspect, everything works fine.
> > > > > >  > > I've tried @Before as well as @After - no luck there. I do see
> > > > > >  > > "weaveinfo Join point..." info in the logs, so things look like they
> > > > > >  > > are being woven. Logging in my code shows everything working through
> > > > > >  > > the service method being invoked and then mysteriously throwing the
> > > > > >  > > InvocationTargetEception. I can only guess that it's coming from the
> > > > > >  > > Advice. I've also tried applying the advice to the class invoked by
> > > > > >  > > the service (in case there's some kind of reflection effect from Axis)
> > > > > >  > > but I still see the same problem.
> > > > > >  > >
> > > > > >  > > I really want to show my boss that AOP is valid for our project but
> > > > > >  > > right now I'm dead in the water. Can someone can help me figure out
> > > > > >  > > what's going on?
> > > > > >  > >
> > > > > >  > > Thanks in advance,
> > > > > >  > > Andy
> > > > > >  > >
> > > > > >  > > Tomcat is configured to run with the JVM opt
> > > > > >  > >
> > > > > > -javaagent:/usr/local/tomcat/shared/lib/aspectjweaver.jar
> > > > > >  > > and shared/lib contains the lib/*.jar files from the AspectJ distro
> > > > > >  > >
> > > > > >  > > Here's my aop.xml
> > > > > >  > >
> > > > > >  > > <aspectj>
> > > > > >  > >       <aspects>
> > > > > >  > >                <aspect name="com.myco.MyAspect"/>
> > > > > >  > >       </aspects>
> > > > > >  > >       <weaver options="-verbose -showWeaveInfo">
> > > > > >  > >               <include within="com.myco.*"/>
> > > > > >  > >       </weaver>
> > > > > >  > > </aspectj>
> > > > > >  > >
> > > > > >  > > Here's my aspect
> > > > > >  > >
> > > > > >  > > package com.myco;
> > > > > >  > >
> > > > > >  > > @Aspect
> > > > > >  > > public class MyAspect
> > > > > >  > > {
> > > > > >  > >
> > > > > >  > > // on any call to our service
> > > > > >  > > @Pointcut("execution( public * com.myco.Service.*(..) )")
> > > > > >  > > void csCall() {}
> > > > > >  > >
> > > > > >  > > // log something
> > > > > >  > > @After("csCall()")
> > > > > >  > > public void logPath()
> > > > > >  > > {
> > > > > >  > >       System.out.println("Aspect logXyPath was called");
> > > > > >  > > }
> > > > > >  > >
> > > > > >  > > }
> > > > > >  >
> > > > > >  > Can you add to the aboves the stacktrace you are getting?
> > > > > >  >
> > > > > >  > ./alex
> > > > > >  > --
> > > > > >  > .w( the_mindstorm )p.
> > > > > >  >
> > > > > >  > _______________________________________________
> > > > > >  > 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
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > 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
> > >
> > _______________________________________________
> > 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
>
>