{"record":{"id":"da2fc7dd9faa633f","repo":"spring-projects/spring-framework","slug":"lookup-method-resolution-failed","errorCode":null,"errorMessage":"Lookup method resolution failed","messagePattern":"Lookup method resolution failed","errorType":"exception","errorClass":"BeanCreationException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java","lineNumber":482,"sourceCode":"\t\t\t\t\t\t\t\tLookupOverride override = new LookupOverride(method, lookup.value());\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tRootBeanDefinition mbd = (RootBeanDefinition)\n\t\t\t\t\t\t\t\t\t\t\tthis.beanFactory.getMergedBeanDefinition(beanName);\n\t\t\t\t\t\t\t\t\tmbd.getMethodOverrides().addOverride(override);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcatch (NoSuchBeanDefinitionException ex) {\n\t\t\t\t\t\t\t\t\tthrow new BeanCreationException(beanName,\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot apply @Lookup to beans without corresponding bean definition\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttargetClass = targetClass.getSuperclass();\n\t\t\t\t\t}\n\t\t\t\t\twhile (targetClass != null && targetClass != Object.class);\n\n\t\t\t\t}\n\t\t\t\tcatch (IllegalStateException ex) {\n\t\t\t\t\tthrow new BeanCreationException(beanName, \"Lookup method resolution failed\", ex);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.lookupMethodsChecked.add(beanName);\n\t\t}\n\t}\n\n\t@Override\n\tpublic PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {\n\t\tInjectionMetadata metadata = findAutowiringMetadata(beanName, bean.getClass(), pvs);\n\t\ttry {\n\t\t\tmetadata.inject(bean, beanName, pvs);\n\t\t}\n\t\tcatch (BeanCreationException ex) {\n\t\t\tthrow ex;\n\t\t}\n\t\tcatch (Throwable ex) {\n\t\t\tthrow new BeanCreationException(beanName, \"Injection of autowired dependencies failed\", ex);\n\t\t}","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java#L464-L500","documentation":"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).","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    context.getBean(MyPrototypeBean.class);\n} catch (BeanCreationException ex) {\n    if (ex.getMessage().contains(\"Lookup method resolution failed\")) {\n        Throwable root = ex.getCause();\n        // inspect root IllegalStateException — likely beanFactory not set\n    }\n}","preventionTips":["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."],"tags":["spring","lookup","bean-creation","debugging"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}