spring-projects/spring-framework · critical · IllegalArgumentException

AdvisorAutoProxyCreator requires a…

Error message

AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: {}

What it means

Thrown by AbstractAdvisorAutoProxyCreator.setBeanFactory (line 63-66) when the supplied BeanFactory is not an instance of ConfigurableListableBeanFactory. Advisor-based auto-proxy creators must query and sort Advisor beans and register dependencies, capabilities that only a ConfigurableListableBeanFactory provides, so any other factory type is rejected at wiring time.

Solutions

  1. Use a standard ApplicationContext (ClassPathXmlApplicationContext, AnnotationConfigApplicationContext, etc.) which always provides a ConfigurableListableBeanFactory.
  2. If constructing programmatically, ensure the bean factory is a DefaultListableBeanFactory (which implements ConfigurableListableBeanFactory).
  3. Avoid passing a restricted/custom BeanFactory implementation to the auto-proxy creator; wrap it in a DefaultListableBeanFactory instead.

Example fix

// before
DefaultAdvisorAutoProxyCreator apc = new DefaultAdvisorAutoProxyCreator();
apc.setBeanFactory(new SimpleJndiBeanFactory()); // not ConfigurableListableBeanFactory

// after
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
// register advisors into bf ...
DefaultAdvisorAutoProxyCreator apc = new DefaultAdvisorAutoProxyCreator();
apc.setBeanFactory(bf);
Defensive patterns

Strategy: validation

Validate before calling

DefaultAdvisorAutoProxyCreator apc = new DefaultAdvisorAutoProxyCreator();
if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
    throw new IllegalStateException(
        "Use a DefaultListableBeanFactory/ApplicationContext for advisor auto-proxying");
}
apc.setBeanFactory(beanFactory);

Type guard

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
static boolean supportsAdvisorAutoProxy(BeanFactory bf) {
    return bf instanceof ConfigurableListableBeanFactory;
}

Prevention

When it happens

Trigger: Registering a DefaultAdvisorAutoProxyCreator, BeanNameAutoProxyCreator descendant that does advisor retrieval, or AnnotationAwareAspectJAutoProxyCreator against a BeanFactory that is not ConfigurableListableBeanFactory (e.g. a manually constructed SimpleJndiBeanFactory, or a custom minimal BeanFactory). Wiring the auto-proxy creator programmatically with 'beanFactory' that is a plain BeanFactory reference.

Common situations: Using a non-ApplicationContext lightweight container in tests. Mis-configuring a custom BeanFactory wrapper that does not extend DefaultListableBeanFactory. Mixing a standalone/portable bean factory abstraction with Spring's auto-proxy support.

Related errors


AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09). Data as JSON: /api/errors/30b17fd487ac194a. Report an issue: GitHub.

Appendix: source

Thrown at spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java:64

 * not annotated with {@code @Order} or don't implement the {@code Ordered}
 * interface will be considered as unordered; they will appear at the end of the
 * advisor chain in an undefined order.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see #findCandidateAdvisors
 */
@SuppressWarnings("serial")
public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator {

	private @Nullable BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper;


	@Override
	public void setBeanFactory(BeanFactory beanFactory) {
		super.setBeanFactory(beanFactory);
		if (!(beanFactory instanceof ConfigurableListableBeanFactory clbf)) {
			throw new IllegalArgumentException(
					"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: " + beanFactory);
		}
		initBeanFactory(clbf);
	}

	protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		this.advisorRetrievalHelper = new BeanFactoryAdvisorRetrievalHelperAdapter(beanFactory);
	}


	@Override
	protected Object @Nullable [] getAdvicesAndAdvisorsForBean(
			Class<?> beanClass, String beanName, @Nullable TargetSource targetSource) {

		List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);
		if (advisors.isEmpty()) {
			return DO_NOT_PROXY;
		}

View on GitHub (pinned to 69bf83ad71)