We used aspectJ to get some metrics in an existing application. When building and weaving with AJDT in eclipse, everything works fine. But into the integration of env. we use ant script to build and deploy the application.
The problem occurs in the ExceptionHandler, which I made to make sure that our aspect will not throw an exception and break the application
@Aspect public class ExceptionHandlerAspect { @Pointcut("within(com.xxx.yyy.aop.aspect.*..*)") public void allMethodInAspectPackage() {} @Pointcut("!within(com.xxx.yyy.aop.aspect.ExceptionHandlerAspect)") public void notInExceptionHandlerAspectClass() {} @Pointcut("call(* *(..))") public void allClassAndMethod() {}
Basically, I want to intercept every call in my package of aspects except ExceptionHandler itself.
The ant construction is as follows:
<iajc inpath="${classes.dir}" destDir="${classes.dir}" fork="true" maxmem="${aspectj.maxmem}" verbose="true" showWeaveInfo="true" debug="true"> <classpath refid="ajclasspath"/> </iajc>
$ {classes.dir} is the class directory in which the javac task created the application and aspects
From the result
Exception in thread "main" java.lang.NoSuchMethodError: com.xxx.yyy.aop.aspect.ExceptionHandlerAspect.aspectOf()Lcom/xxx/yyy/aop/aspect/ExceptionHandlerAspect; at com.xxx.yyy.aop.aspect.ecs.AspectBaseEcs.inspectLoginInfo(AspectBaseEcs.java:65) at com.xxx.yyy.app.es.security.Security.loadApplications(Security.java:172) at com.xxx.yyy.app.es.gui.VSDlgLogin.loadSecurity(VSDlgLogin.java:346) at com.xx.yyy.app.es.ApplicationSuite.start(ApplicationSuite.java:839) at com.xxx.yyy.app.es.ApplicationSuite.main(ApplicationSuite.java:501)
it looks like the ExceptionHandler was not gossip !!!
I hope someone can help me with this -)
Cygnusx1
source share