{"record":{"id":"5c1c80ed895fd779","repo":"spring-projects/spring-framework","slug":"no-matching-bean-found-for-bean-name-not","errorCode":null,"errorMessage":"No matching {} bean found for bean name '{}'! (Note: Qualifier matching not supported because given BeanFactory does not implement ConfigurableListableBeanFactory.)","messagePattern":"No matching (.+?) bean found for bean name '(.+?)'! \\(Note: Qualifier matching not supported because given BeanFactory does not implement ConfigurableListableBeanFactory\\.\\)","errorType":"exception","errorClass":"NoSuchBeanDefinitionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java","lineNumber":104,"sourceCode":"\t * @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found\n\t * @throws BeansException if the bean could not be created\n\t * @see BeanFactoryUtils#beanOfTypeIncludingAncestors(ListableBeanFactory, Class)\n\t */\n\tpublic static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier)\n\t\t\tthrows BeansException {\n\n\t\tAssert.notNull(beanFactory, \"BeanFactory must not be null\");\n\n\t\tif (beanFactory instanceof ListableBeanFactory lbf) {\n\t\t\t// Full qualifier matching supported.\n\t\t\treturn qualifiedBeanOfType(lbf, beanType, qualifier);\n\t\t}\n\t\telse if (beanFactory.containsBean(qualifier) && beanFactory.isTypeMatch(qualifier, beanType)) {\n\t\t\t// Fallback: target bean at least found by bean name.\n\t\t\treturn beanFactory.getBean(qualifier, beanType);\n\t\t}\n\t\telse {\n\t\t\tthrow new NoSuchBeanDefinitionException(qualifier, \"No matching \" + beanType.getSimpleName() +\n\t\t\t\t\t\" bean found for bean name '\" + qualifier +\n\t\t\t\t\t\"'! (Note: Qualifier matching not supported because given \" +\n\t\t\t\t\t\"BeanFactory does not implement ConfigurableListableBeanFactory.)\");\n\t\t}\n\t}\n\n\t/**\n\t * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a qualifier\n\t * (for example, {@code <qualifier>} or {@code @Qualifier}) matching the given qualifier).\n\t * @param beanFactory the factory to get the target bean from\n\t * @param beanType the type of bean to retrieve\n\t * @param qualifier the qualifier for selecting between multiple bean matches\n\t * @return the matching bean of type {@code T} (never {@code null})\n\t */\n\tprivate static <T> T qualifiedBeanOfType(ListableBeanFactory beanFactory, Class<T> beanType, String qualifier) {\n\t\tString[] candidateBeans = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, beanType);\n\t\tString matchingBean = null;\n\t\tfor (String beanName : candidateBeans) {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java#L86-L122","documentation":"Thrown by the public qualifiedBeanOfType(BeanFactory, Class, String) when the provided BeanFactory does not implement ListableBeanFactory (which provides enumeration capabilities), so qualifier-based matching is impossible, AND there is no bean with the given name matching the given type. The message explicitly notes that qualifier matching requires a ConfigurableListableBeanFactory.","triggerScenarios":"Calling BeanFactoryAnnotationUtils.qualifiedBeanOfType() with a minimal BeanFactory (e.g., a SimpleJndiBeanFactory or custom BeanFactory that is not a ListableBeanFactory). The factory has no bean named by the qualifier string, or the named bean's type does not match.","commonSituations":"Using a custom or JNDI-backed BeanFactory that only supports getBean by name. Passing a qualifier that is actually meant as a @Qualifier annotation value rather than a bean name when the factory cannot enumerate beans.","solutions":["Use a ListableBeanFactory (e.g., DefaultListableBeanFactory or any ApplicationContext) so full qualifier matching is supported.","If only a plain BeanFactory is available, ensure the qualifier string matches a registered bean name of the correct type.","Switch to a standard ApplicationContext-based lookup which implements ConfigurableListableBeanFactory."],"exampleFix":"// before\nBeanFactoryAnnotationUtils.qualifiedBeanOfType(\n    simpleBeanFactory, MyService.class, \"myQualifier\"); // not Listable\n\n// after\nBeanFactoryAnnotationUtils.qualifiedBeanOfType(\n    applicationContext, MyService.class, \"myQualifier\");","handlingStrategy":"validation","validationCode":"// Validate the BeanFactory supports qualifier matching before calling\nif (!(beanFactory instanceof ListableBeanFactory)) {\n    // fallback: use bean name directly\n    if (beanFactory.containsBean(qualifier)) {\n        T bean = beanFactory.getBean(qualifier, beanType);\n    } else {\n        throw new IllegalStateException(\"Cannot resolve qualifier on non-Listable BeanFactory\");\n    }\n} else {\n    T bean = BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, beanType, qualifier);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use an ApplicationContext (which is a ListableBeanFactory) for qualifier-based lookups.","If stuck with a plain BeanFactory, ensure the qualifier string matches a registered bean name.","Check beanFactory instanceof ListableBeanFactory before calling qualifiedBeanOfType."],"tags":["spring","qualifier","bean-factory","lookup"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}