spring-projects/spring-framework · error · IllegalStateException

Failed to resolve pointcut expression in: {annotation}

Error message

Failed to resolve pointcut expression in: {annotation}

What it means

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.

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 69bf83ad71)

Solutions

  1. Provide a valid pointcut expression in the 'value' (or 'pointcut') attribute of the advice annotation.
  2. If using a referenced @Pointcut, ensure the reference expression itself is non-empty and resolvable.
  3. Run a quick grep for advice annotations with empty parentheses and fill them in.

Example fix

// before
@Before("")
public void checkAuth() { ... }
// after
@Before("execution(* com.example.Service.*(..))")
public void checkAuth() { ... }
Defensive patterns

Strategy: validation

Validate before calling

import org.springframework.core.annotation.AnnotationUtils;
import org.aspectj.lang.annotation.*;

public static void assertAdvicePointcutsNonEmpty(Class<?> aspectClass) {
    for (Method m : aspectClass.getDeclaredMethods()) {
        for (var a : m.getAnnotations()) {
            if (a instanceof Around || a instanceof Before || a instanceof After ||
                a instanceof AfterReturning || a instanceof AfterThrowing) {
                String expr = (String) AnnotationUtils.getValue(a, "value");
                if (expr == null || expr.isEmpty()) {
                    expr = (String) AnnotationUtils.getValue(a, "pointcut");
                }
                if (expr == null || expr.isEmpty()) {
                    throw new IllegalStateException("Advice " + m + " has empty pointcut");
                }
            }
        }
    }
}

Try / catch

try {
    List<Advisor> advisors = advisorFactory.getAdvisors(factory);
} catch (IllegalStateException ex) {
    if (ex.getMessage().startsWith("Failed to resolve pointcut expression")) {
        // find the advice annotation with empty value/pointcut and fix it
    } else throw ex;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09). Data as JSON: /api/errors/295675cbf1ac4c1a. Report an issue: GitHub.