I'm trying to get a pointcut working.
This pointcut works:
@Around("execution(public * my.package..*ClassSuffix.*(..))")
But this pointcut does not:
@Around("execution(public * my.package..*ClassSuffix.*(..)) && !@target(my.package.NoLogging)")
The exception is
DEBUG o.s.aop.aspectj.AspectJExpressionPointcut - Could not access current invocation - matching with limited context: java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation is in progress, and that the ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically, note that advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor!
DEBUG o.s.aop.aspectj.AspectJExpressionPointcut - Failed to evaluate join point for arguments [] - falling back to non-match
java.lang.NullPointerException: null
at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit(ShadowMatchImpl.java:195)
at org.aspectj.weaver.ast.HasAnnotation.accept(HasAnnotation.java:31)
at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.matches(ShadowMatchImpl.java:132)
at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.visit(ShadowMatchImpl.java:163)
at org.aspectj.weaver.ast.Not.accept(Not.java:26)
at org.aspectj.weaver.reflect.ShadowMatchImpl$RuntimeTestEvaluator.matches(ShadowMatchImpl.java:132)
at org.aspectj.weaver.reflect.ShadowMatchImpl.matchesJoinPoint(ShadowMatchImpl.java:87)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:357)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:174)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at my.package.FooClassSuffix$$EnhancerBySpringCGLIB$$e7bc07ac.doSomething(<generated>)
So it seems that the more complex pointcut requires some context, and ExposeInvocationInterceptor#invoke(..)
is called at some point, but not at the right point because ExposeInvocationInterceptor#currentInvocation()
throws an exception?
Is there something wrong with the pointcut? I used this as a reference: https://stackoverflow.com/a/38866088/361414
Pointcuts are defined in a class with these annotations:
@Aspect
@Component
@Order(20)