{"id":"cdaf4d8cf3cdda82","repo":"spring-projects/spring-framework","slug":"customautowireconfigurer-needs-to-operate-on-a-def","errorCode":null,"errorMessage":"CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory","messagePattern":"CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java","lineNumber":94,"sourceCode":"\t * when autowiring beans. Each element of the provided set may\n\t * be either a Class instance or a String representation of the\n\t * fully-qualified class name of the custom annotation.\n\t * <p>Note that any annotation that is itself annotated with Spring's\n\t * {@link org.springframework.beans.factory.annotation.Qualifier}\n\t * does not require explicit registration.\n\t * @param customQualifierTypes the custom types to register\n\t */\n\tpublic void setCustomQualifierTypes(Set<?> customQualifierTypes) {\n\t\tthis.customQualifierTypes = customQualifierTypes;\n\t}\n\n\n\t@Override\n\t@SuppressWarnings(\"unchecked\")\n\tpublic void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {\n\t\tif (this.customQualifierTypes != null) {\n\t\t\tif (!(beanFactory instanceof DefaultListableBeanFactory dlbf)) {\n\t\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\t\"CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory\");\n\t\t\t}\n\t\t\tif (!(dlbf.getAutowireCandidateResolver() instanceof QualifierAnnotationAutowireCandidateResolver)) {\n\t\t\t\tdlbf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());\n\t\t\t}\n\t\t\tQualifierAnnotationAutowireCandidateResolver resolver =\n\t\t\t\t\t(QualifierAnnotationAutowireCandidateResolver) dlbf.getAutowireCandidateResolver();\n\t\t\tfor (Object value : this.customQualifierTypes) {\n\t\t\t\tClass<? extends Annotation> customType = null;\n\t\t\t\tif (value instanceof Class) {\n\t\t\t\t\tcustomType = (Class<? extends Annotation>) value;\n\t\t\t\t}\n\t\t\t\telse if (value instanceof String className) {\n\t\t\t\t\tcustomType = (Class<? extends Annotation>) ClassUtils.resolveClassName(className, this.beanClassLoader);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\t\"Invalid value [\" + value + \"] for custom qualifier type: needs to be Class or String.\");","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java#L76-L112","documentation":"Error \"CustomAutowireConfigurer needs to operate on a DefaultListableBeanFactory\" thrown in spring-projects/spring-framework.","triggerScenarios":"Thrown at spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}