{"id":"fc06fd9cbe67522c","repo":"spring-projects/spring-framework","slug":"servicelocatorfactorybean-needs-to-run-in-a-beanfa","errorCode":null,"errorMessage":"ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory","messagePattern":"ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory","errorType":"exception","errorClass":"FatalBeanException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java","lineNumber":250,"sourceCode":"\n\t/**\n\t * Set mappings between service ids (passed into the service locator)\n\t * and bean names (in the bean factory). Service ids that are not defined\n\t * here will be treated as bean names as-is.\n\t * <p>The empty string as service id key defines the mapping for {@code null} and\n\t * empty string, and for factory methods without parameter. If not defined,\n\t * a single matching bean will be retrieved from the bean factory.\n\t * @param serviceMappings mappings between service ids and bean names,\n\t * with service ids as keys as bean names as values\n\t */\n\tpublic void setServiceMappings(Properties serviceMappings) {\n\t\tthis.serviceMappings = serviceMappings;\n\t}\n\n\t@Override\n\tpublic void setBeanFactory(BeanFactory beanFactory) throws BeansException {\n\t\tif (!(beanFactory instanceof ListableBeanFactory lbf)) {\n\t\t\tthrow new FatalBeanException(\n\t\t\t\t\t\"ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory\");\n\t\t}\n\t\tthis.beanFactory = lbf;\n\t}\n\n\t@Override\n\tpublic void afterPropertiesSet() {\n\t\tif (this.serviceLocatorInterface == null) {\n\t\t\tthrow new IllegalArgumentException(\"Property 'serviceLocatorInterface' is required\");\n\t\t}\n\n\t\t// Create service locator proxy.\n\t\tthis.proxy = Proxy.newProxyInstance(\n\t\t\t\tthis.serviceLocatorInterface.getClassLoader(),\n\t\t\t\tnew Class<?>[] {this.serviceLocatorInterface},\n\t\t\t\tnew ServiceLocatorInvocationHandler());\n\t}\n","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java#L232-L268","documentation":"Error \"ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory\" thrown in spring-projects/spring-framework.","triggerScenarios":"Thrown at spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java:250 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}