Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] LTW in Tomcat 6.0.14

When you use Spring and LTW, you have to add this line in the file applicationContext.xml of your web-app :

<context:load-time-weave/> in the mbeans element.

See more info http://www.springindepth.com/book/aop-load-time-weaving.html

And particular cases with Tomcat

 

Cordialement / Best regards

 

Jean-Louis Pasturel
jeanlouis.pasturel@xxxxxxxxxxxxxxxxxx

 


De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Sudhar
Envoyé : jeudi 23 avril 2009 23:06
À : aspectj-users@xxxxxxxxxxx
Objet : [aspectj-users] LTW in Tomcat 6.0.14

 

I am trying to do the LTW to dynamically configure the classes that participate in advice and trying to deploy the setup in a web application in Tomcat 6.*.
I have created a simple aspect class with logging to entry and exit of method calls in a class. And configured the LTW in aop.xml. The whole setup works as standalone in Eclipse but NOT in Tomcat.

This is what I did for Tomcat deployment:
- Used AJDT to compile the source code and aspect. Simply converted the project to AspectJProject and moved all the compiled class files to Tomcat webapp/WEB-INF/classes folder
- Copied the aop.xml to webapp/WEB-INF/classes/META-INF folder
- Copied all aspectJ jars to Tomcat/lib
- Modified the JVM to include -javaagent:TomcatHome\lib\aspectjweaver.jar

And I see the following outputs in Tomcat but nothing getting weaved. Am I missing something? Do I need to change anything in Tomcat setting?

[JasperLoader@3002b9] info AspectJ Weaver Version 1.6.3 built on Tuesday Dec 23, 2008 at 17:12:30 GMT
[JasperLoader@3002b9] info register classloader org.apache.jasper.servlet.JasperLoader@3002b9
[JasperLoader@3002b9] info using configuration /C:/apache-tomcat-6.0.14/webapps/ccnn/WEB-INF/classes/META-INF/aop.xml
[JasperLoader@3002b9] info using configuration file:/C:/apache-tomcat-6.0.14/webapps/ccnn/WEB-INF/lib/spring-aspects.jar!/META-INF/aop.xml
[JasperLoader@3002b9] info register aspect TraceAspect
[JasperLoader@3002b9] info register aspect org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect
[JasperLoader@3002b9] info register aspect org.springframework.transaction.aspectj.AnnotationTransactionAspect

TraceAspect is my aspect class and the other aspects are coming from Spring. Here is my aop.xml definition.

<aspectj>
            <aspects>
              <aspect name="TraceAspect"> </aspect>
              <weaver options="-verbose -showWeaveInfo">
          </weaver>
            </aspects>

 </aspectj>    

And here is my TraceAspect definition:

import gov.bean.ListOfValue;
import gov.bean.CCNNDocument;

import org.aspectj.lang.Signature;

public abstract aspect TraceAspect{
    /**
     * Application classes.
     */
    pointcut myClass1(): within(CCNNDocument) || within(ListOfValue);
    /**
     * The constructors in those classes.
     */
    pointcut myConstructor1(): myClass1() && execution(new(..));
    /**
     * The methods of those classes.
     */
    pointcut myMethod1(): myClass1() && execution(* *(..));

    /**
     * Prints trace messages before and after executing constructors.
     */
    before (): myConstructor1() {
        Trace.traceEntry("myConstructor1 - before" + thisJoinPointStaticPart.getSignature());
    }
    after(): myConstructor1() {
        Trace.traceExit("myConstructor1 - after" + thisJoinPointStaticPart.getSignature());
    }

    /**
     * Prints trace messages before and after executing methods.
     */
    before (): myMethod1() {
        Trace.traceEntry("myMethod1 - before" + thisJoinPointStaticPart.getSignature());
    }
    after(): myMethod1() {
        Trace.traceExit("myMethod1 - after" + thisJoinPointStaticPart.getSignature());
    }
    Object around() : myMethod1(){
        Signature sig = thisJoinPointStaticPart.getSignature();
        long start = System.currentTimeMillis();
        try {
            return proceed();
        } finally {
            long end = System.currentTimeMillis();
            Trace.traceExit("Time taken by [" + sig.getDeclaringType().getName() + "."
                    + sig.getName() + "]" + (end-start));
        }
    }
   
}


Thanks,
- Sudharsan.

*********************************
This message and any attachments (the "message") are confidential and intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration.
France Telecom Group shall not be liable for the message if altered, changed or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
********************************

Back to the top