1

my question is related to this question

We have different aspect class that do @around advice on different part of an application (fat client in Swing) to measure the execution time.

I have another aspect (ExceptionHandler) that do @around on all the aspects method i wrote.

I did this to avoid that the aspects created would throw exception and make the client application fails. So basically, i try catch the Proceed of my other @around method and just log exception that arise. I only throw an exception when i detect it come from the proceedingJoinPoint

if (joinPoint.getSignature().getDeclaringTypeName().equalsIgnoreCase("org.aspectj.lang.ProceedingJoinPoint")) {
            throw exception;
        }

Is it valid to do this?

In Eclipse with AJDT the app run fine and i tested the ExceptionHandler and it worked as expected.

But in other env. (Integration) the application fail as soon as it meet a line advised by the exceptionHandler with this Error

Exception in thread "main" java.lang.NoSuchMethodError:     com.xxx.yyy.aop.aspect.ExceptionHandlerAspect.aspect
 Of()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.xxx.yyy.app.es.ApplicationSuite.start(ApplicationSuite.java:839)
    at com.xxx.yyy.app.es.ApplicationSuite.main(ApplicationSuite.java:501)

I have also decompile the code to see if aspectOf() was weaved into my ExceptionHandler and the method is there!!!!!!!???????????

Why this error rise...?

I'm clueless.

Community
  • 1
  • 1
Cygnusx1
  • 5,329
  • 2
  • 27
  • 39

1 Answers1

0

Finally found the problem. Our Application had a dependency on common module jar that was containing aspect too.

The base package name was the same : com.xxx.aop and the base class we used for our aspects was the same name!!!! So 2 com.xxx.aop.AspectBase.class were loaded.

Since we used a flag in our ant build file to enable compile time weaving at yes/no, one of our AspectBase.class was not weaved while the other was.

Can't believe i didn't see that before!!!!!

Cygnusx1
  • 5,329
  • 2
  • 27
  • 39