spring-projects/spring-framework · error · BeanCreationException
Lookup method resolution failed
Error message
Lookup method resolution failed
What it means
A wrapper BeanCreationException thrown from checkLookupMethods() when an IllegalStateException occurs during the resolution of @Lookup-annotated methods. The underlying cause is attached so the developer can inspect the real problem. This is a catch-all for unexpected reflective or state errors during lookup-method processing, distinct from the missing-bean-definition case (error 201).
Solutions
- Ensure the AutowiredAnnotationBeanPostProcessor has its beanFactory set before any bean processing occurs — use a standard Spring context rather than manual wiring.
- Inspect the cause (ex.getCause()) of the BeanCreationException to find the real IllegalStateException and address that root issue.
- Verify @Lookup methods are on Spring-managed beans processed through the normal container refresh cycle.
Defensive patterns
Strategy: try-catch
Try / catch
try {
context.getBean(MyPrototypeBean.class);
} catch (BeanCreationException ex) {
if (ex.getMessage().contains("Lookup method resolution failed")) {
Throwable root = ex.getCause();
// inspect root IllegalStateException — likely beanFactory not set
}
} Prevention
- Use standard Spring context refresh rather than manual post-processor invocation.
- Ensure BeanFactory is set on AutowiredAnnotationBeanPostProcessor before bean creation.
- Inspect cause chains on BeanCreationException to find the underlying IllegalStateException.
When it happens
Trigger: The inner do-with-methods lambda or the surrounding loop throws an IllegalStateException that is not a NoSuchBeanDefinitionException. Possible triggers include beanFactory being null (Assert.state at line 463 fails) or a concurrency-related state corruption during class hierarchy traversal.
Common situations: Calling determineCandidateConstructors or postProcessProperties before the BeanFactory has been fully initialized or set on the AutowiredAnnotationBeanPostProcessor. Using the post-processor outside a normal Spring container lifecycle (e.g., in a custom bootstrap).
Related errors
- Cannot apply @Lookup to beans without corresponding bean…
- Injection of autowired dependencies failed
- Invocation of init method failed
- No matching bean found for bean name ' '! (Note: Qualifier…
- Unexpected MethodOverride subclass:
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/da2fc7dd9faa633f.
Report an issue: GitHub.
Appendix: source
Thrown at spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java:482
LookupOverride override = new LookupOverride(method, lookup.value());
try {
RootBeanDefinition mbd = (RootBeanDefinition)
this.beanFactory.getMergedBeanDefinition(beanName);
mbd.getMethodOverrides().addOverride(override);
}
catch (NoSuchBeanDefinitionException ex) {
throw new BeanCreationException(beanName,
"Cannot apply @Lookup to beans without corresponding bean definition");
}
}
});
targetClass = targetClass.getSuperclass();
}
while (targetClass != null && targetClass != Object.class);
}
catch (IllegalStateException ex) {
throw new BeanCreationException(beanName, "Lookup method resolution failed", ex);
}
}
this.lookupMethodsChecked.add(beanName);
}
}
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
InjectionMetadata metadata = findAutowiringMetadata(beanName, bean.getClass(), pvs);
try {
metadata.inject(bean, beanName, pvs);
}
catch (BeanCreationException ex) {
throw ex;
}
catch (Throwable ex) {
throw new BeanCreationException(beanName, "Injection of autowired dependencies failed", ex);
}View on GitHub (pinned to 69bf83ad71)