aspectj - Spring Boot load time weaving doesn't work in embedded tomcat -


i can't ltw work in spring boot 1.2.2 w/ embedded tomcat.

my application war file, not .jar file. when run in debug, never stops in aspect hitting calls should match pointcuts, how figure not working...

my run script this:

-javaagent:path/to/spring-instrument-xxx.jar -javaagent:path/to/aspectjweaver-1.2.8.jar 

in spring boot, load aop config applicationinitializer, in parent applicationcontext right away , should there rest of embedded tomcat web application context thereafter.

@enableloadtimeweaving(aspectjweaving=aspectjweaving.enabled) @configuration public class aopconfig {     private log log = logfactory.getlog(aopconfig.class);      public aopconfig() {         log.info("creating aopconfig");     }      @bean     public loadtimeweaver loadtimeweaver() {         log.info("creating instrumentationloadtimeweaver");         return new instrumentationloadtimeweaver();     } } 

my aspect looks this:

package my.aop.profiler.methodtimeraspect;  @aspect public class methodtimeraspect {     private static final string delimiter = "|";     private static final string profiler = "profiler";     private static final string date_format = "h:mm:ss";     private static final log log = logfactory.getlog(profiler);      public methodtimeraspect() {}      @pointcut("execution (* my.web.*controller.*(..))")     protected void controllers() {}      @pointcut("execution (* my.services..*facade.*(..))")     protected void services() {}      @pointcut("execution (* my.services..*exchange.*(..))")     protected void data() {}      /**      * if profiling enabled trace, log amount of time      * spent in method      *      * @param joinpoint      * @return object      * @throws throwable      */     @around("controllers() || services() || data()")     public object doprofiling(proceedingjoinpoint joinpoint) throws throwable {         // (...)     } } 

my embedded war's meta-inf/aop.xml this:

<!doctype aspectj public "-//aspectj//dtd//en" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> <aspectj>     <weaver>         <!-- weave classes in our application-specific packages -->         <include within="cdot.*"/>     </weaver>     <aspects>         <!-- weave in aspect -->         <aspect name="my.aop.profiler.methodtimeraspect"/>     </aspects> </aspectj> 

two ideas:

  • probably want change 1 of pointcuts find subpackages (use .. syntax instead of .):

    @pointcut("execution (* my.web..*controller.*(..))") 
  • the same applies aop.xml:

    <include within="cdot..*"/> 

i assume my.web changed deliberately , reads cdot.something, because otherwise pointcuts not match.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -