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

Here's a datapoint: I got LTW working in Resin 3.1.6, but it ignored the weaver options (in the <weaver> element).  If I wanted to debug, I had to set one of the system parameters, i.e.

-Dorg.aspectj.weaver.showWeaveInfo=true

Other than that, it processed my aop.xml just file.  Come to think of it, I ought to make a bug report..

Best,

Larry Edelstein
Senior Member of Technical Staff
salesforce.com

On Thu, Apr 23, 2009 at 2:06 PM, Sudhar <sudhar.suba@xxxxxxxxx> wrote:
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.



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top