spring-projects/spring-framework · error · IllegalStateException
Failed to resolve pointcut expression in: {}
Error message
Failed to resolve pointcut expression in: {} What it means
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.
Source
Thrown at spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java:208
}
}
private AspectJAnnotationType determineAnnotationType(Annotation annotation) {
AspectJAnnotationType type = annotationTypeMap.get(annotation.annotationType());
if (type != null) {
return type;
}
throw new IllegalStateException("Unknown annotation type: " + annotation);
}
private String resolvePointcutExpression(Annotation annotation) {
for (String attributeName : EXPRESSION_ATTRIBUTES) {
Object val = AnnotationUtils.getValue(annotation, attributeName);
if (val instanceof String str && !str.isEmpty()) {
return str;
}
}
throw new IllegalStateException("Failed to resolve pointcut expression in: " + annotation);
}
public AspectJAnnotationType getAnnotationType() {
return this.annotationType;
}
public Annotation getAnnotation() {
return this.annotation;
}
public String getPointcutExpression() {
return this.pointcutExpression;
}
public String getArgumentNames() {
return this.argumentNames;
}
View on GitHub (pinned to e8729d0438)
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()").
Example fix
// before
@Before("")
public void beforeAdvice() { ... }
// after
@Before("execution(* com.acme.service.*.*(..))")
public void beforeAdvice() { ... } Defensive patterns
Strategy: validation
Validate before calling
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.AnnotationUtils;
import java.lang.reflect.Method;
void requirePointcutExpression(Method m) {
Before b = AnnotationUtils.findAnnotation(m, Before.class);
if (b != null && b.value().isBlank())
throw new IllegalArgumentException("@Before on " + m + " has empty pointcut");
// repeat for Around, After, AfterReturning, AfterThrowing, Pointcut as needed
} Prevention
- 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.
When it happens
Trigger: An advice method annotated like @Before("") or @Before (with no value and no separate pointcut attribute), passed through ReflectiveAspectJAdvisorFactory when building advisors.
Common situations: 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.
Related errors
- Found {} potential annotation variable(s) and {} potential a
- Found {} candidate annotation binding variables but only one
- Number of pointcut parameter names must match number of poin
- Must set property 'expression' before attempting to match
- {} is not a valid AspectJ annotation
AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04).
Data as JSON: /data/errors/77faa514527954eb.json.
Report an issue: GitHub.