Le 21/06/2011 03:31, joliver a écrit :
Hi There,

I've been getting accustomed to AspectJ over the last few days and have
created numerous stand-alone applications where I have effectively used LTW.

For example:

public class TestClass {
        private int x;
        private int y;

        public TestClass(int x, int y) {
                this.x = x;
                this.y = y;
        }

        public int getX() {
                return x;
        }

        public void setX(int x) {
                this.x = x;
        }

        public int getY() {
                return y;
        }

        public void setY(int y) {
                this.y = y;
        }

        public static void main(String[] args) {
                TestClass tc = new TestClass(1, 2);
                tc = new TestClass(1, 2);
                tc = new TestClass(1, 2);

        }

}

Aspect:
public aspect TestAspect {
        after() returning(TestClass tc): call(TestClass.new(..)) {
                tc.setY(1000);
                 System.out.println("JUST CREATED A TC!!!!!!!! " + tc.getY());
        }
}

aop.xml:
<aspectj>
             <aspects>
               <aspect name="jon.sandbox.aspect.TestAspect"/>
             </aspects>

             <weaver options="-verbose">
             </weaver>

</aspectj>

When I run this from the command line it works great!  I run it like:
java -classpath "<the classpath>" -javaagent:aspectjweaver.jar



My problems start when I try to get this to work in a servlet running in
Tomcat 6.

I have basically created a servlet and in the doGet() method I'm
instantiating a TestClass.  I've added a -javaagent:aspectjweaver.jar to the
startup and the Weaver starts and registers my Aspect but when I actually
come to run the servlet no LTW occurs!?!?

What gives?  What am I missing or doing wrong??

Any help would be greatly appreciated!

--
View this message in context: 
http://aspectj.2085585.n4.nabble.com/LTW-not-running-in-my-WebApp-tp3612958p3612958.html
Sent from the AspectJ - users mailing list archive at Nabble.com.
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

It is because the default ClassLoader of Tomcat is not "instrumentable". All is explained in this thread : http://forum.springsource.org/showthread.php?88613-load-time-weaver-and-tomcat-6-problem!

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to