alibaba/spring-cloud-alibaba · error · IllegalStateException
{type} create fail
Error message
{type} create fail What it means
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.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/feign/SentinelFeign.java:162
Class fallbackType, Class targetType) {
FeignClientFactory factory = Builder.this.feignClientFactory;
if (factory == null) {
throw new IllegalStateException("FeignClientFactory not initialized");
}
Object fallbackInstance = factory.getInstance(name,
fallbackType);
if (fallbackInstance == null) {
throw new IllegalStateException(String.format(
"No %s instance of type %s found for feign client %s",
type, fallbackType, name));
}
// when fallback is a FactoryBean, should determine the type of instance
if (fallbackInstance instanceof FactoryBean<?> factoryBean) {
try {
fallbackInstance = factoryBean.getObject();
}
catch (Exception e) {
throw new IllegalStateException(type + " create fail", e);
}
if (fallbackInstance == null) {
throw new IllegalStateException(type + " FactoryBean returned null");
}
fallbackType = fallbackInstance.getClass();
}
if (!targetType.isAssignableFrom(fallbackType)) {
throw new IllegalStateException(String.format(
"Incompatible %s instance. Fallback/fallbackFactory of type %s is not assignable to %s for feign client %s",
type, fallbackType, targetType, name));
}
return fallbackInstance;
}
});
super.contract(new SentinelContractHolder(contract));
return super.internalBuild();View on GitHub (pinned to 115d590110)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
Object safeGetObject(FactoryBean<?> fb) {
try { return fb.getObject(); }
catch (Exception e) { throw new IllegalStateException("FactoryBean getObject failed for " + fb.getClass(), e); }
} Try / catch
try { inst = factoryBean.getObject(); }
catch (Exception e) { log.error("fallback factory bean failed", e); /* fall back to default or fail fast */ throw e; } Prevention
- Inspect the wrapped cause, not just the Sentinel message.
- Unit-test FactoryBean.getObject() in isolation.
- Prefer plain @Component fallbacks over FactoryBeans.
When it happens
Trigger: 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).
Common situations: A FactoryBean that depends on resources not yet initialized. A protobuf/proxy FactoryBean that fails to build the proxy. Misconfigured factory bean properties.
Related errors
- {type} FactoryBean returned null
- FeignClientFactoryBean not found for {targetType}
- FeignClientFactory not initialized
- No %s instance of type %s found for feign client %s
- Incompatible %s instance. Fallback/fallbackFactory of type %
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/cb70d98d15130d07.
Report an issue: GitHub.