alibaba/spring-cloud-alibaba · critical · IllegalStateException
NacosConfigManager not available
Error message
NacosConfigManager not available
What it means
Thrown by NacosConfigDataLoader.doLoad during Spring Boot config-data import when getBean(context, NacosConfigManager.class) returns null. The NacosConfigManager bean is expected to be registered in the bootstrap context (NacosConfigDataLocationResolver.registerConfigManager registers it only when spring.config.import nacos entries exist). A null here means that registration did not happen before the loader tried to pull remote config.
Source
Thrown at spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/configdata/NacosConfigDataLoader.java:80
private final Log log;
public NacosConfigDataLoader(DeferredLogFactory logFactory) {
this.log = logFactory.getLog(getClass());
}
@Override
public @Nullable ConfigData load(ConfigDataLoaderContext context,
NacosConfigDataResource resource) {
return doLoad(context, resource);
}
public @Nullable ConfigData doLoad(ConfigDataLoaderContext context,
NacosConfigDataResource resource) {
try {
NacosConfigManager configManager = getBean(context, NacosConfigManager.class);
if (configManager == null) {
throw new IllegalStateException("NacosConfigManager not available");
}
ConfigService configService = configManager.getConfigService();
NacosConfigProperties properties = getBean(context,
NacosConfigProperties.class);
if (properties == null) {
throw new IllegalStateException("NacosConfigProperties not available");
}
NacosItemConfig config = resource.getConfig();
// pull config from nacos
List<PropertySource<?>> propertySources = pullConfig(configService,
config.getGroup(), config.getDataId(), config.getSuffix(),
properties.getTimeout(), properties.getNamespace());
NacosPropertySource propertySource = new NacosPropertySource(propertySources,
config.getGroup(), config.getDataId(), new Date(),
config.isRefreshEnabled());
propertySource.setSuffix(config.getSuffix());View on GitHub (pinned to 115d590110)
Solutions
- Ensure spring.config.import includes a nacos: entry (e.g., spring.config.import=nacos:app.yml) AND spring.cloud.nacos.config.server-addr is set so the autoconfiguration registers NacosConfigManager.
- Do not exclude NacosConfigAutoConfiguration / the relevant autoconfiguration classes when importing nacos: locations.
- Match Spring Boot / spring-cloud-alibaba versions so the bootstrap-context registration runs before the loader.
- Confirm no custom ConfigDataLocationResolver overrode registerConfigManager.
Example fix
// application.yml
# before (import without config props -> manager never registered)
spring:
config:
import: "nacos:app.yml"
# after
spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
config:
import: "nacos:app.yml" Defensive patterns
Strategy: validation
Validate before calling
// Before importing nacos: locations, ensure the manager will be registered: spring.config.import must be non-empty AND nacos config props set.
assert environment.getProperty("spring.config.import") != null;
assert environment.getProperty("spring.cloud.nacos.config.server-addr") != null; Prevention
- Always pair spring.config.import=nacos:... with spring.cloud.nacos.config.server-addr.
- Do not exclude the Nacos config autoconfiguration when importing nacos: locations.
- Match spring-cloud-alibaba version with your Spring Boot version.
When it happens
Trigger: spring.config.import references nacos: URIs but the NacosConfigManager was not registered — e.g., the resolver's registerConfigManager was skipped because SPRING_CONFIG_IMPORT_PROPERTIES was empty, the bootstrap context was reset/replaced, or the autoconfiguration that registers the manager is disabled/excluded.
Common situations: Misconfigured spring.cloud.nacos.config / spring.config.import; excluding the Nacos config autoconfiguration while still importing nacos: locations; a Spring Boot version mismatch where the bootstrap-context registration ordering changed; a custom ConfigDataLocationResolver that bypasses registerConfigManager.
Related errors
- NacosConfigProperties not available
- dataId must be specified
- illegal URI: {uris}
- illegal dataId
- Binder not available in BootstrapContext
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/6c45cbdb9fb7b5d8.
Report an issue: GitHub.