Error at :: 0 cannot find pointcut binding reference

I am trying to create an aspect to control the execution of certain methods. When I tried to run the test, I get this error:

Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut annotation at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207) 

when ApplicationContext loads.

I define the annotation as:

 @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.METHOD, ElementType.TYPE }) public @interface TimePerformance { } 

And this is the aspect code:

 @Aspect public class MonitorImpl{ private static final Log LOG = LogFactory.getLog(MonitorImpl.class); @Pointcut(value="execution(public * *(..))") public void anyPublicMethod() { } @Around("anyPublicMethod() && annotation(timePerformance)") public Object timePerformance(ProceedingJoinPoint pjp,TimePerformance timePerformance) throws Throwable { if (LOG.isInfoEnabled()) { LOG.info("AOP - Before executing "+pjp.getSignature()); } Long startTime = System.currentTimeMillis(); Object result = pjp.proceed(); Long stopTime = System.currentTimeMillis(); LOG.info("MONITOR TIME_EXECUTION "+pjp.getSignature()+" : "+(stopTime-startTime)); if (LOG.isInfoEnabled()) { LOG.info("AOP - After executing "+pjp.getSignature()); } return result; } } 

And the configuration:

 <!-- AOP support --> <bean id='stateAspectImpl' class='eu.genetwister.snpaware.ui.aspect.StateAspectImpl' /> <bean id='monitorImpl' class='eu.genetwister.snpaware.monitor.MonitorImpl' /> <aop:aspectj-autoproxy> <aop:include name='stateAspectImpl' /> <aop:include name='monitorImpl' /> </aop:aspectj-autoproxy> 

I just checked a lot of questions here, but most of them give a solution to use aspectj version 1.7. I use:

  <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.7.0</version> </dependency> 

Another solution points to the variable name in the method signature, but as you can see, there is no error.

Does anyone know where the problem is?

thanks

+3
source share
2 answers

I solve the problem using this configuration in class aspect

 @Around("execution(* *(..)) && @annotation(timePerformance)") public Object timePerformance(ProceedingJoinPoint pjp, TimePerformance timePerformance) throws Throwable 

But the problem now, the aspect is not fulfilled.

0
source

You just miss @ before the annotation in your pointcut.

 @Around("anyPublicMethod() && @annotation(timePerformance)") ^ 
+9
source

All Articles