{"id":"18888d23be8fe78a","repo":"spring-projects/spring-framework","slug":"advisorautoproxycreator-requires-a-configurablelis","errorCode":null,"errorMessage":"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: {beanFactory}","messagePattern":"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java","lineNumber":64,"sourceCode":" * not annotated with {@code @Order} or don't implement the {@code Ordered}\n * interface will be considered as unordered; they will appear at the end of the\n * advisor chain in an undefined order.\n *\n * @author Rod Johnson\n * @author Juergen Hoeller\n * @see #findCandidateAdvisors\n */\n@SuppressWarnings(\"serial\")\npublic abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator {\n\n\tprivate @Nullable BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper;\n\n\n\t@Override\n\tpublic void setBeanFactory(BeanFactory beanFactory) {\n\t\tsuper.setBeanFactory(beanFactory);\n\t\tif (!(beanFactory instanceof ConfigurableListableBeanFactory clbf)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: \" + beanFactory);\n\t\t}\n\t\tinitBeanFactory(clbf);\n\t}\n\n\tprotected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) {\n\t\tthis.advisorRetrievalHelper = new BeanFactoryAdvisorRetrievalHelperAdapter(beanFactory);\n\t}\n\n\n\t@Override\n\tprotected Object @Nullable [] getAdvicesAndAdvisorsForBean(\n\t\t\tClass<?> beanClass, String beanName, @Nullable TargetSource targetSource) {\n\n\t\tList<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);\n\t\tif (advisors.isEmpty()) {\n\t\t\treturn DO_NOT_PROXY;\n\t\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java#L46-L82","documentation":"AbstractAdvisorAutoProxyCreator.setBeanFactory() requires the factory to be a ConfigurableListableBeanFactory because it must register a BeanFactoryAdvisorRetrievalHelperAdapter and introspect bean definitions. A plain BeanFactory (or non-ConfigurableListable) cannot support advisor retrieval, so IllegalArgumentException is thrown during context setup.","triggerScenarios":"Wiring an AdvisorAutoProxyCreator (DefaultAdvisorAutoProxyCreator, or annotation-driven infrastructure that builds one) into a container that supplies a non-ConfigurableListableBeanFactory; programmatically calling setBeanFactory() with a custom minimal BeanFactory.","commonSituations":"Custom lightweight containers; misconfigured bean factory post-processing; embedding Spring AOP in a non-standard environment; using a static/legacy BeanFactory instead of an ApplicationContext.","solutions":["Use a Spring ApplicationContext (ClassPathXmlApplicationContext, AnnotationConfigApplicationContext) which always provides a ConfigurableListableBeanFactory.","If wiring manually, pass an instance of DefaultListableBeanFactory.","Ensure no custom BeanFactory decorator strips the ConfigurableListable interface."],"exampleFix":"// before\nBeanFactory bf = new SimpleJndiBeanFactory(); // not listable\nautoProxyCreator.setBeanFactory(bf);\n\n// after\nDefaultListableBeanFactory bf = new DefaultListableBeanFactory();\nautoProxyCreator.setBeanFactory(bf);","handlingStrategy":"validation","validationCode":"if (!(beanFactory instanceof org.springframework.beans.factory.config.ConfigurableListableBeanFactory)) {\n    throw new IllegalStateException(\"Auto-proxy creator requires ConfigurableListableBeanFactory, got: \" + beanFactory.getClass());\n}\nautoProxyCreator.setBeanFactory(beanFactory);","typeGuard":"public static boolean isConfigurableListable(BeanFactory bf) {\n    return bf instanceof org.springframework.beans.factory.config.ConfigurableListableBeanFactory;\n}","tryCatchPattern":null,"preventionTips":["Bootstrap AOP inside an ApplicationContext (always provides a ConfigurableListableBeanFactory).","When wiring programmatically, pass a DefaultListableBeanFactory.","Avoid decorator BeanFactories that hide the ConfigurableListable interface."],"tags":["aop","auto-proxy","bean-factory","configuration"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}