spring-projects/spring-framework · error · NoSuchBeanDefinitionException
No matching {} bean found for bean name '{}'! (Note: Qualifi
Error message
No matching {} bean found for bean name '{}'! (Note: Qualifier matching not supported because given BeanFactory does not implement ConfigurableListableBeanFactory.) What it means
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.
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java:104
* @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found
* @throws BeansException if the bean could not be created
* @see BeanFactoryUtils#beanOfTypeIncludingAncestors(ListableBeanFactory, Class)
*/
public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier)
throws BeansException {
Assert.notNull(beanFactory, "BeanFactory must not be null");
if (beanFactory instanceof ListableBeanFactory lbf) {
// Full qualifier matching supported.
return qualifiedBeanOfType(lbf, beanType, qualifier);
}
else if (beanFactory.containsBean(qualifier) && beanFactory.isTypeMatch(qualifier, beanType)) {
// Fallback: target bean at least found by bean name.
return beanFactory.getBean(qualifier, beanType);
}
else {
throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() +
" bean found for bean name '" + qualifier +
"'! (Note: Qualifier matching not supported because given " +
"BeanFactory does not implement ConfigurableListableBeanFactory.)");
}
}
/**
* Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a qualifier
* (for example, {@code <qualifier>} or {@code @Qualifier}) matching the given qualifier).
* @param beanFactory the factory to get the target bean from
* @param beanType the type of bean to retrieve
* @param qualifier the qualifier for selecting between multiple bean matches
* @return the matching bean of type {@code T} (never {@code null})
*/
private static <T> T qualifiedBeanOfType(ListableBeanFactory beanFactory, Class<T> beanType, String qualifier) {
String[] candidateBeans = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, beanType);
String matchingBean = null;
for (String beanName : candidateBeans) {View on GitHub (pinned to 69bf83ad71)
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.
Example fix
// before
BeanFactoryAnnotationUtils.qualifiedBeanOfType(
simpleBeanFactory, MyService.class, "myQualifier"); // not Listable
// after
BeanFactoryAnnotationUtils.qualifiedBeanOfType(
applicationContext, MyService.class, "myQualifier"); Defensive patterns
Strategy: validation
Validate before calling
// Validate the BeanFactory supports qualifier matching before calling
if (!(beanFactory instanceof ListableBeanFactory)) {
// fallback: use bean name directly
if (beanFactory.containsBean(qualifier)) {
T bean = beanFactory.getBean(qualifier, beanType);
} else {
throw new IllegalStateException("Cannot resolve qualifier on non-Listable BeanFactory");
}
} else {
T bean = BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, beanType, qualifier);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot apply @Lookup to beans without corresponding bean def
- Lookup method resolution failed
- No qualifying bean of type '{}' available: expected single m
- No matching {} bean found for qualifier '{}' - neither quali
- CustomAutowireConfigurer needs to operate on a DefaultListab
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/5c1c80ed895fd779.
Report an issue: GitHub.