{"record":{"id":"cb70d98d15130d07","repo":"alibaba/spring-cloud-alibaba","slug":"type-create-fail","errorCode":null,"errorMessage":"{type} create fail","messagePattern":"(.+?) create fail","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":162,"sourceCode":"\t\t\t\t\t\tClass fallbackType, Class targetType) {\n\t\t\t\t\tFeignClientFactory factory = Builder.this.feignClientFactory;\n\t\t\t\t\tif (factory == null) {\n\t\t\t\t\t\tthrow new IllegalStateException(\"FeignClientFactory not initialized\");\n\t\t\t\t\t}\n\t\t\t\t\tObject fallbackInstance = factory.getInstance(name,\n\t\t\t\t\t\t\tfallbackType);\n\t\t\t\t\tif (fallbackInstance == null) {\n\t\t\t\t\t\tthrow new IllegalStateException(String.format(\n\t\t\t\t\t\t\t\t\"No %s instance of type %s found for feign client %s\",\n\t\t\t\t\t\t\t\ttype, fallbackType, name));\n\t\t\t\t\t}\n\t\t\t\t\t// when fallback is a FactoryBean, should determine the type of instance\n\t\t\t\t\tif (fallbackInstance instanceof FactoryBean<?> factoryBean) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tfallbackInstance = factoryBean.getObject();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\t\tthrow new IllegalStateException(type + \" create fail\", e);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fallbackInstance == null) {\n\t\t\t\t\t\t\tthrow new IllegalStateException(type + \" FactoryBean returned null\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfallbackType = fallbackInstance.getClass();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!targetType.isAssignableFrom(fallbackType)) {\n\t\t\t\t\t\tthrow new IllegalStateException(String.format(\n\t\t\t\t\t\t\t\t\"Incompatible %s instance. Fallback/fallbackFactory of type %s is not assignable to %s for feign client %s\",\n\t\t\t\t\t\t\t\ttype, fallbackType, targetType, name));\n\t\t\t\t\t}\n\t\t\t\t\treturn fallbackInstance;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tsuper.contract(new SentinelContractHolder(contract));\n\t\t\treturn super.internalBuild();","sourceCodeStart":144,"sourceCodeEnd":180,"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#L144-L180","documentation":"If the resolved fallback instance is itself a Spring FactoryBean, SentinelFeign calls getObject() to obtain the real instance. When that call throws, the exception is wrapped in this IllegalStateException ('{type} create fail'), where {type} is fallback or fallbackFactory. It surfaces a failure inside the factory bean, not in Sentinel itself.","triggerScenarios":"A fallback declared as a FactoryBean whose getObject() throws (e.g. fails to construct the target, hits a downstream dependency, or returns based on missing config).","commonSituations":"A FactoryBean that depends on resources not yet initialized. A protobuf/proxy FactoryBean that fails to build the proxy. Misconfigured factory bean properties.","solutions":["Inspect the wrapped cause (the original Exception) to find the real failure in getObject().","Ensure all dependencies the FactoryBean needs are available and initialized before the feign client is built.","Fix or replace the failing FactoryBean; if it cannot reliably produce instances, use a plain @Component fallback instead.","Reproduce getObject() in a unit test against the FactoryBean in isolation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Object safeGetObject(FactoryBean<?> fb) {\n  try { return fb.getObject(); }\n  catch (Exception e) { throw new IllegalStateException(\"FactoryBean getObject failed for \" + fb.getClass(), e); }\n}","typeGuard":null,"tryCatchPattern":"try { inst = factoryBean.getObject(); }\ncatch (Exception e) { log.error(\"fallback factory bean failed\", e); /* fall back to default or fail fast */ throw e; }","preventionTips":["Inspect the wrapped cause, not just the Sentinel message.","Unit-test FactoryBean.getObject() in isolation.","Prefer plain @Component fallbacks over FactoryBeans."],"tags":["sentinel","feign","fallback","factorybean"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}