{"record":{"id":"25bd0a03f88e9747","repo":"alibaba/nacos","slug":"500-25bd0a","errorCode":"500","errorMessage":"Cannot initialize CmdbService!","messagePattern":"Cannot initialize CmdbService!","errorType":"error_code","errorClass":"NacosException","httpStatus":500,"severity":"error","filePath":"cmdb/src/main/java/com/alibaba/nacos/cmdb/memory/CmdbProvider.java","lineNumber":79,"sourceCode":"    private Map<String, Map<String, Entity>> entityMap = new ConcurrentHashMap<>();\n    \n    private Map<String, Label> labelMap = new ConcurrentHashMap<>();\n    \n    private Set<String> entityTypeSet = new HashSet<>();\n    \n    private long eventTimestamp = System.currentTimeMillis();\n    \n    public CmdbProvider() throws NacosException {\n    }\n    \n    private void initCmdbService() throws NacosException {\n        Iterator<CmdbService> iterator = services.iterator();\n        if (iterator.hasNext()) {\n            cmdbService = iterator.next();\n        }\n        \n        if (cmdbService == null && switches.isLoadDataAtStart()) {\n            throw new NacosException(NacosException.SERVER_ERROR, \"Cannot initialize CmdbService!\");\n        }\n    }\n    \n    /**\n     * load data.\n     */\n    public void load() {\n        \n        if (!switches.isLoadDataAtStart()) {\n            return;\n        }\n        \n        // init label map:\n        Set<String> labelNames = cmdbService.getLabelNames();\n        if (labelNames == null || labelNames.isEmpty()) {\n            Loggers.MAIN.warn(\"[LOAD] init label names failed!\");\n        } else {\n            for (String labelName : labelNames) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/cmdb/src/main/java/com/alibaba/nacos/cmdb/memory/CmdbProvider.java#L61-L97","documentation":"Thrown by CmdbProvider.initCmdbService() with error code SERVER_ERROR (500) when no CmdbService SPI implementation is found on the classpath AND the configuration switch 'loadDataAtStart' is enabled. CmdbProvider loads CmdbService implementations via NacosServiceLoader (SPI); if the iterator has no elements, cmdbService remains null. If loadDataAtStart is true, the server cannot start CMDB functionality and throws. If loadDataAtStart is false, this is silently skipped.","triggerScenarios":"The CMDB module is deployed with nacos.cmdb.loadDataAtStart=true but no CmdbService implementation JAR is on the classpath. The CmdbService SPI file (META-INF/nacos/com.alibaba.nacos.api.cmdb.spi.CmdbService) is missing or empty.","commonSituations":"Custom CMDB deployment where the service implementation JAR was not included; fat-jar packaging stripped SPI metadata; the cmdb module was built without the implementation dependency; a fresh deployment forgot to include the CMDB plugin.","solutions":["Set nacos.cmdb.loadDataAtStart=false (or SwitchAndOptions equivalent) if CMDB data loading is not needed.","If CMDB is needed, ensure the CmdbService implementation JAR is on the classpath and its SPI file is present under META-INF/nacos/.","Verify the SPI file content lists the fully-qualified class name of your CmdbService implementation."],"exampleFix":"// before — CMDB enabled but no implementation\n// application.properties or custom.properties:\nnacos.cmdb.loadDataAtStart=true\n\n// after — disable if not needed, or add the implementation JAR\nnacos.cmdb.loadDataAtStart=false","handlingStrategy":"validation","validationCode":"boolean loadDataAtStart = switches.isLoadDataAtStart();\nCollection<CmdbService> services = NacosServiceLoader.load(CmdbService.class);\nif (loadDataAtStart && services.isEmpty()) {\n    throw new IllegalStateException(\"loadDataAtStart is true but no CmdbService SPI implementation found.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    cmdbProvider.initCmdbService();\n} catch (NacosException e) {\n    if (e.getErrCode() == NacosException.SERVER_ERROR && e.getMessage().contains(\"CmdbService\")) {\n        // Disable CMDB loading or provide a stub implementation\n        switches.setLoadDataAtStart(false);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Set nacos.cmdb.loadDataAtStart=false if no CmdbService implementation is deployed.","Verify the CmdbService SPI file is present on the classpath when CMDB is enabled.","Include the CMDB plugin JAR in your server deployment when loadDataAtStart is true."],"tags":["server","cmdb","spi","configuration","startup"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}