{"record":{"id":"295675cbf1ac4c1a","repo":"spring-projects/spring-framework","slug":"failed-to-resolve-pointcut-expression-in-annotat","errorCode":null,"errorMessage":"Failed to resolve pointcut expression in: {annotation}","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/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java#L190-L226","documentation":"Thrown as an IllegalStateException from AspectJAnnotation.resolvePointcutExpression() when neither the 'pointcut' nor the 'value' attribute of a recognized AspectJ advice annotation resolves to a non-empty String. A valid AspectJ advice annotation must carry a pointcut expression (either inline in value/pointcut or via a referenced pointcut). This indicates the annotation is structurally recognized but its pointcut expression is missing/empty.","triggerScenarios":"An advice method annotated with e.g. @Before() or @Before(\"\") (empty pointcut); a meta-annotation that masks the 'value' attribute; an @Around with neither 'value' nor 'pointcut' set because the annotation was applied programmatically with defaults overridden to empty.","commonSituations":"Empty pointcut string left during development/templating; refactoring that accidentally cleared the pointcut expression; copy-paste from an example that used a referenced pointcut (@Pointcut) but the reference was dropped leaving an empty value.","solutions":["Provide a valid pointcut expression in the 'value' (or 'pointcut') attribute of the advice annotation.","If using a referenced @Pointcut, ensure the reference expression itself is non-empty and resolvable.","Run a quick grep for advice annotations with empty parentheses and fill them in."],"exampleFix":"// before\n@Before(\"\")\npublic void checkAuth() { ... }\n// after\n@Before(\"execution(* com.example.Service.*(..))\")\npublic void checkAuth() { ... }","handlingStrategy":"validation","validationCode":"import org.springframework.core.annotation.AnnotationUtils;\nimport org.aspectj.lang.annotation.*;\n\npublic static void assertAdvicePointcutsNonEmpty(Class<?> aspectClass) {\n    for (Method m : aspectClass.getDeclaredMethods()) {\n        for (var a : m.getAnnotations()) {\n            if (a instanceof Around || a instanceof Before || a instanceof After ||\n                a instanceof AfterReturning || a instanceof AfterThrowing) {\n                String expr = (String) AnnotationUtils.getValue(a, \"value\");\n                if (expr == null || expr.isEmpty()) {\n                    expr = (String) AnnotationUtils.getValue(a, \"pointcut\");\n                }\n                if (expr == null || expr.isEmpty()) {\n                    throw new IllegalStateException(\"Advice \" + m + \" has empty pointcut\");\n                }\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    List<Advisor> advisors = advisorFactory.getAdvisors(factory);\n} catch (IllegalStateException ex) {\n    if (ex.getMessage().startsWith(\"Failed to resolve pointcut expression\")) {\n        // find the advice annotation with empty value/pointcut and fix it\n    } else throw ex;\n}","preventionTips":["Always supply a non-empty pointcut expression to advice annotations.","Add a unit test that loads each aspect and asserts advisorFactory.getAdvisors(factory) succeeds.","Lint aspect sources for empty advice annotations."],"tags":["spring-aop","aspectj","pointcut","configuration"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}