{"record":{"id":"88d1fe644e5463ce","repo":"alibaba/spring-cloud-alibaba","slug":"feignclientfactorybean-not-found-for-targettype","errorCode":null,"errorMessage":"FeignClientFactoryBean not found for {targetType}","messagePattern":"FeignClientFactoryBean not found for (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/feign/SentinelFeign.java","lineNumber":113,"sourceCode":"\n\t\t\t\t\t// If you need the attributes to be resolved lazily, set the property value to true.\n\t\t\t\t\tBoolean isLazyInit = ctx.getEnvironment()\n\t\t\t\t\t\t\t.getProperty(FEIGN_LAZY_ATTR_RESOLUTION, Boolean.class, false);\n\t\t\t\t\tif (isLazyInit) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Due to the change of the initialization sequence,\n\t\t\t\t\t\t * BeanFactory.getBean will cause a circular dependency. So\n\t\t\t\t\t\t * FeignClientFactoryBean can only be obtained from BeanDefinition\n\t\t\t\t\t\t */\n\t\t\t\t\t\tfeignClientFactoryBean = (FeignClientFactoryBean) def\n\t\t\t\t\t\t\t\t.getAttribute(\"feignClientsRegistrarFactoryBean\");\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tfeignClientFactoryBean = (FeignClientFactoryBean) ctx\n\t\t\t\t\t\t\t\t.getBean(\"&\" + target.type().getName());\n\t\t\t\t\t}\n\t\t\t\t\tif (feignClientFactoryBean == null) {\n\t\t\t\t\t\tthrow new IllegalStateException(\"FeignClientFactoryBean not found for \" + target.type().getName());\n\t\t\t\t\t}\n\t\t\t\t\tClass fallback = feignClientFactoryBean.getFallback();\n\t\t\t\t\tClass fallbackFactory = feignClientFactoryBean.getFallbackFactory();\n\t\t\t\t\tString beanName = feignClientFactoryBean.getContextId();\n\t\t\t\t\tif (!StringUtils.hasText(beanName)) {\n\t\t\t\t\t\t@Nullable Object nameValue = getFieldValue(feignClientFactoryBean, \"name\");\n\t\t\t\t\t\tbeanName = nameValue != null ? (String) nameValue : \"unknown\";\n\t\t\t\t\t}\n\n\t\t\t\t\tObject fallbackInstance;\n\t\t\t\t\tFallbackFactory fallbackFactoryInstance;\n\t\t\t\t\t// check fallback and fallbackFactory properties\n\t\t\t\t\tif (void.class != fallback) {\n\t\t\t\t\t\tfallbackInstance = getFromContext(beanName, \"fallback\", fallback,\n\t\t\t\t\t\t\t\ttarget.type());\n\t\t\t\t\t\treturn new SentinelInvocationHandler(target, dispatch,\n\t\t\t\t\t\t\t\tnew FallbackFactory.Default(fallbackInstance));\n\t\t\t\t\t}","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/feign/SentinelFeign.java#L95-L131","documentation":"To resolve a feign client's fallback/fallbackFactory, SentinelFeign looks up the FeignClientFactoryBean that registered the client. Depending on the lazy-init flag it either reads an attribute from the bean definition or fetches the factory bean by '&'+name. If neither yields a FeignClientFactoryBean, this IllegalStateException is thrown at client build time.","triggerScenarios":"A @FeignClient whose registration did not go through FeignClientsRegistrar (so the 'feignClientsRegistrarFactoryBean' attribute is absent) and the '&name' bean lookup also fails. Custom feign client registration that bypasses the standard factory bean.","commonSituations":"Registering feign clients via FeignClientBuilder.create() instead of @FeignClients/FeignClientFactoryBean. A framework version mismatch where the attribute key changed. Manually providing a feign client bean of the wrong type.","solutions":["Register clients with @FeignClients and let FeignClientFactoryBean manage them.","If using a non-lazy path, ensure the FactoryBean is registered under the conventional '&<fully-qualified-name>' bean name.","Align spring-cloud-openfeign and spring-cloud-alibaba-sentinel versions so the registrar attribute key matches.","Avoid providing your own bean definition that shadows the FeignClientFactoryBean."],"exampleFix":"// before: manual bean registration without factory bean\n@Bean MyApi myApi() { return FeignClientBuilder.create().api(MyApi.class); }\n// after\n@FeignClient(name = \"myApi\", fallback = MyApiFallback.class)\npublic interface MyApi { ... }","handlingStrategy":"validation","validationCode":"void ensureFactoryBean(BeanDefinitionRegistry r, String name) {\n  if (!r.containsBeanDefinition(name) && !r.containsBeanDefinition(\"&\" + name))\n    throw new IllegalStateException(\"No FeignClientFactoryBean for \" + name + \"; register via @FeignClient\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register feign clients via @FeignClients only.","Keep spring-cloud-openfeign and sentinel starter versions aligned.","Avoid shadowing the FeignClientFactoryBean with custom beans."],"tags":["sentinel","feign","fallback","registration"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}