{"id":"77faa514527954eb","repo":"spring-projects/spring-framework","slug":"failed-to-resolve-pointcut-expression-in","errorCode":null,"errorMessage":"Failed to resolve pointcut expression in: {}","messagePattern":"Failed to resolve pointcut expression in: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java","lineNumber":208,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tprivate AspectJAnnotationType determineAnnotationType(Annotation annotation) {\n\t\t\tAspectJAnnotationType type = annotationTypeMap.get(annotation.annotationType());\n\t\t\tif (type != null) {\n\t\t\t\treturn type;\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Unknown annotation type: \" + annotation);\n\t\t}\n\n\t\tprivate String resolvePointcutExpression(Annotation annotation) {\n\t\t\tfor (String attributeName : EXPRESSION_ATTRIBUTES) {\n\t\t\t\tObject val = AnnotationUtils.getValue(annotation, attributeName);\n\t\t\t\tif (val instanceof String str && !str.isEmpty()) {\n\t\t\t\t\treturn str;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Failed to resolve pointcut expression in: \" + annotation);\n\t\t}\n\n\t\tpublic AspectJAnnotationType getAnnotationType() {\n\t\t\treturn this.annotationType;\n\t\t}\n\n\t\tpublic Annotation getAnnotation() {\n\t\t\treturn this.annotation;\n\t\t}\n\n\t\tpublic String getPointcutExpression() {\n\t\t\treturn this.pointcutExpression;\n\t\t}\n\n\t\tpublic String getArgumentNames() {\n\t\t\treturn this.argumentNames;\n\t\t}\n","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java#L190-L226","documentation":"Thrown by AspectJAnnotation.resolvePointcutExpression() when neither the 'pointcut' nor the 'value' attribute of an AspectJ advice/pointcut annotation yields a non-empty String. Every @Before/@Around/@After/@AfterReturning/@AfterThrowing/@Pointcut annotation must carry a pointcut expression (directly or via the 'value' attribute), otherwise Spring cannot build the pointcut. An empty or blank expression is treated as absent.","triggerScenarios":"An advice method annotated like @Before(\"\") or @Before (with no value and no separate pointcut attribute), passed through ReflectiveAspectJAdvisorFactory when building advisors.","commonSituations":"Developer forgets to fill in the pointcut expression; uses a placeholder empty string; copies a template aspect without completing the expression; a refactoring leaves the advice annotation empty.","solutions":["Supply a valid pointcut expression to the advice annotation's value/pointcut attribute.","Reference a named @Pointcut method via the annotation value (e.g. @Before(\"com.acme.MyAspect.somePointcut()\")."],"exampleFix":"// before\n@Before(\"\")\npublic void beforeAdvice() { ... }\n// after\n@Before(\"execution(* com.acme.service.*.*(..))\")\npublic void beforeAdvice() { ... }","handlingStrategy":"validation","validationCode":"import org.aspectj.lang.annotation.*;\nimport org.springframework.core.annotation.AnnotationUtils;\nimport java.lang.reflect.Method;\n\nvoid requirePointcutExpression(Method m) {\n  Before b = AnnotationUtils.findAnnotation(m, Before.class);\n  if (b != null && b.value().isBlank())\n    throw new IllegalArgumentException(\"@Before on \" + m + \" has empty pointcut\");\n  // repeat for Around, After, AfterReturning, AfterThrowing, Pointcut as needed\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave advice annotation values blank; fill in the expression before committing.","Add a unit test that scans @Aspect classes for empty pointcut expressions.","Reference shared @Pointcut methods to avoid duplication and blank-value mistakes."],"tags":["spring-aop","aspectj","pointcut","annotation"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}