[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to compile an aspect for Load time weaving using ajc

>From a quick look you are suffering from the same thing as someone did
a few days ago on the list.  By default we don't allow weaving of
java.* types or javax.* types - as it is easy to get in a mess (weave
java.lang.String and you'd be in trouble...).  If you are weaving
those types you need to include an extra weaver option:

Here is the earlier post:
----
I think you are possibly being affected by the code we have that
prevents LTW of anything beginning java.* or javax.* :)  See this
bugzilla entry from a while back
https://bugs.eclipse.org/bugs/show_bug.cgi?id=149261 : "Allow weaving
javax..* types"

In which case, you need to download a recent dev build of AspectJ from
the downloads page and use the option:

<weaver options="-Xset:weaveJavaxPackages=true"/>
----

The warning you get on compilation about the type not being found is
fine and shouldn't affect the ability to use the aspect for LTW with
the real type.

Andy.

On 31/01/2008, Pradeep_ Kumar <pradeep_kumar@xxxxxxxxxxxxxxxxxx> wrote:
> Thanks a lot Andy.......
>
> Here I am keying in my situation, please have a look at that and if possible let me know what all I need to do:
>
> The following is code of the aspect that I am using:
> ============
>
> package com.btsl.aspects;
>
> import javax.servlet.http.HttpServlet;
>
> public aspect BTSLAspect {
>
>         /** Execution of any Servlet request methods. */
>           public pointcut monitoredOperation(HttpServlet servlet) :
>             execution(void HttpServlet.do*(..)) && this(servlet);
>
>           /** Advice that records statistics for each monitored operation. */
>           void around(HttpServlet servlet) : monitoredOperation(servlet) {
>                   System.err.println("=================");
>                   System.err.println("Its working......");
>                   System.err.println("==================");
>                 //  proceed(operation);
>           }
>
> }
> ================
>
> And when I compile it on Window XP using aspectJ 1.5 with the following comand
> =====================
> C:\work\dev\AspectJ>ajc -1.5 -cp C:\work\dev\AspectJ\servlet.jar;%CLASSPATH% com
> \btsl\aspects\BTSLAspect.java
> C:\work\dev\AspectJ\com\btsl\aspects\BTSLAspect.java:12 [warning] advice defined
>  in com.btsl.aspects.BTSLAspect has not been applied [Xlint:adviceDidNotMatch]
>
> 1 warning
>
> C:\work\dev\AspectJ>
> ======================
>
> I am using JDK 1.5 (jdk1.5.0_12) and passing -1.5 flag as well while compiling the aspect through ajc
>
> And then I copy the generated BTSLAspect.class file in webapps\servlets-examples\WEB-INF\classes\com\btsl\aspects folder, I have already created aop.xml file in META-INF folder under classes folder
>
> ===== aop.xml ====
> <aspectj>
> <aspects>
> <aspect name="com.btsl.aspects.BTSLAspect"/>
> </aspects>
> <weaver options="-verbose -debug showWeaveInfo">
> <include within="javax.*"/>
> </weaver>
> </aspectj>
> ======
>
>
> But when I hit any servelet on tomcat instance, I get following messge on tomcat console:
> ========
> [WebappClassLoader@5ddb6e] debug not weaving 'HelloWorldExample'
> Jan 31, 2008 9:29:04 AM org.apache.catalina.core.ApplicationContext log
> INFO: InvokerFilter(ApplicationFilterConfig[name=Path Mapped Filter, filterClass
> =filters.ExampleFilter]): 78 milliseconds
> =======================
>
> I have put all the required file and set agent weaver in tomcat which I think working fine.
>
> Please let me know what step(s) I am missing or any thing I am doing wrong.
>
> I think I am not able to complile my aspect (BTSLAspect.java) correctly. Do I need to include some other files as well? Please let me know
>
> Thanks and Regards
> PRADEEP KUMAR
> Solution Architect
> +91 99100 71728 | Bharti Telesoft Ltd. New Delhi-20 | Extension: 1311
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
> Sent: Thursday, January 31, 2008 5:52 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] How to compile an aspect for Load time weaving using ajc
>
> I am not sure about to put it when you've built it - but to compile it
> just use straight ajc - if there are types it refers to directly
> rather than through wildcard patterns then they will need to be on the
> classpath ideally.  If it is using java5 you will need to specify the
> -1.5 flag.
>
> Or use AJDT to build it if you are in Eclipse.
>
> Andy.
>
> On 30/01/2008, Pradeep_ Kumar <pradeep_kumar@xxxxxxxxxxxxxxxxxx> wrote:
> >
> >
> >
> >
> > Hi Everyone,
> >
> >
> >
> > I am trying to use AspectJ to monitor my servlets running on Tomact 5.5.  I
> > have configured Tomcat properly but don't know how to compile my aspect that
> > I have already written.  For example my aspect is HttpMonitor.java.  Please
> > let me know how can I compile it using ajc.
> >
> >
> >
> > If I am not wrong then I need to compile my aspect first and then need to
> > copy in classes folder of my web application.
> >
> >
> >
> >
> >
> > Thanks and Regards
> >
> > PRADEEP KUMAR
> >
> > Solution Architect
> >
> > +91 99100 71728 | Bharti Telesoft Ltd. New Delhi-20 | Extension: 1311
> >
> >
> >  ________________________________
> >  This e-mail and all material transmitted with it are for the use of the
> > intended recipient(s) ONLY and contains confidential and/or privileged
> > information. If you are not the intended recipient, please contact the
> > sender by reply e-mail and destroy all copies and the original message. Any
> > unauthorized review, use, disclosure, dissemination, forwarding, printing or
> > copying of this email or any action taken pursuant to the contents of the
> > present e-mail is strictly prohibited and is unlawful.
> >  The recipient acknowledges that Bharti Telesoft Limited or its management
> > or directors, are unable to exercise control or ensure the integrity over
> > /of the contents of the information contained in e-mail. Any views expressed
> > herein are those of the individual sender only and no binding nature of the
> > contents shall be implied or assumed unless the sender does so expressly
> > with due authority of Bharti Telesoft Limited. E-mail and any contents
> > transmitted with it are prone to viruses and related defects despite all
> > efforts to avoid such by Bharti Telesoft Limited.
> >
> > _______________________________________________
> > 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
>
> This e-mail and all material transmitted with it are for the use of the intended recipient(s) ONLY and contains confidential and/or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken pursuant to the contents of the present e-mail is strictly prohibited and is unlawful.
> The recipient acknowledges that Bharti Telesoft Limited or its management or directors, are unable to exercise control or ensure the integrity over /of the contents of the information contained in e-mail. Any views expressed herein are those of the individual sender only and no binding nature of the contents shall be implied or assumed unless the sender does so expressly with due authority of Bharti Telesoft Limited. E-mail and any contents transmitted with it are prone to viruses and related defects despite all efforts to avoid such by Bharti Telesoft Limited.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>