Skip to content
Advertisement

Spring AOP @Pointcut and @Before yields IllegalArgumentException: error at ::0 formal unbound in pointcut

I am doing a springboot project that includes login and accounts. I am trying to @Pointcut all controller method calls and validate the login information, and @Before the pointcut to make sure the session exists. Hence the code:

JavaScript

However, this yields org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor' defined in class path resource [org/springframework/data/web/config/ProjectingArgumentResolverRegistrar.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut.

Deleting the validateSession() and @Before makes the @Pointcut work. How can I fix this?

Advertisement

Answer

The problem is that you define a JoinPoint parameter in the pointcut. It only belongs in the advice method using the pointcut, not in the pointcut itself. You are not using it there anyway because a pointcut is never executed, the method is just a dummy to be decorated by the @Poinctut annotation. So what you want is this:

JavaScript

Besides (and unrelated to your problem), the .*.* is quite specific and only matches a method in a class which is exactly in package show.xianwu.game.frisbeescorer.controller. If you want to also include classes in subpackages, use the .. syntax instead, in this case show.xianwu.game.frisbeescorer.controller..*.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement