Search code examples
springspring-bootaspectj

UnsupportedPointcutPrimitiveException: Pointcut expression 'getEncryptedValue()' contains unsupported pointcut primitive 'get'


I was using spring-boot-starter-parent 2.0.3-RELEASE, using pointcut primitive 'get' in my aspect like below.

@Pointcut("get(* *) && @annotation(com.test.cryptography.EncryptEnabled)")
    public void getEncryptedValue() {
    }

But when I upgrade the spring boot version to 2.6.6 it starts failing with below error.

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 org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'getEncryptedValue()' contains unsupported pointcut primitive 'get'

Is there any change I need to do for the latest spring release


Solution

  • As described in the Spring manual, chapter Supported Pointcut Designators, get() is unavailable in Spring AOP. I.e., if it worked for you before, you must have used native AspectJ, possibly via LTW (load-time weaving).

    Therefore, if it is not working anymore after your Spring (Boot) upgrade, you probably just have a configuration issue, maybe something as simple as having forgotten to re-add a JMV parameter -javaagent:/path/to/aspectjweaver.jar, which probably you were using before.