{"record":{"id":"9169d003b6b93994","repo":"MyCATApache/Mycat-Server","slug":"selfcheck-user-name-refered-schemas-is-empty","errorCode":null,"errorMessage":"SelfCheck### user {name}refered schemas is empty!","messagePattern":"SelfCheck### user (.+?)refered schemas is empty!","errorType":"exception","errorClass":"io.mycat.config.ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/ConfigInitializer.java","lineNumber":136,"sourceCode":"\t\tthis.selfChecking0();\n\t}\n\t\n\tprivate void selfChecking0() throws ConfigException {\n\t\t\n\t\t// 检查user与schema配置对应以及schema配置不为空\n\t\tif (users == null || users.isEmpty()) {\n\t\t\tthrow new ConfigException(\"SelfCheck### user all node is empty!\");\n\t\t\t\n\t\t} else {\n\t\t\t\n\t\t\tfor (UserConfig uc : users.values()) {\n\t\t\t\tif (uc == null) {\n\t\t\t\t\tthrow new ConfigException(\"SelfCheck### users node within the item is empty!\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tSet<String> authSchemas = uc.getSchemas();\n\t\t\t\tif (authSchemas == null) {\n\t\t\t\t\tthrow new ConfigException(\"SelfCheck### user \" + uc.getName() + \"refered schemas is empty!\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (String schema : authSchemas) {\n\t\t\t\t\tif ( !schemas.containsKey(schema) ) {\n\t\t\t\t\t\tString errMsg = \"SelfCheck###  schema \" + schema + \" refered by user \" + uc.getName() + \" is not exist!\";\n\t\t\t\t\t\tthrow new ConfigException(errMsg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t\t\n\t\t// schema 配置检测\t\t\n\t\tfor (SchemaConfig sc : schemas.values()) {\n\t\t\tif (null == sc) {\n\t\t\t\tthrow new ConfigException(\"SelfCheck### schema all node is empty!\");\n\t\t\t\t\n\t\t\t} else {\t\t\t\t","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/ConfigInitializer.java#L118-L154","documentation":"Thrown by MyCat's ConfigInitializer during startup self-check (selfChecking0) when a user entry in the users config node has a null schemas set. MyCat requires every configured user to reference at least one logical schema for authorization, so a user without schemas makes the config invalid and startup is aborted with ConfigException.","triggerScenarios":"Booting or reloading MyCat (ConfigInitializer constructor) with a server.xml user element that has no schemas attribute, or a UserConfig whose getSchemas() returns null (e.g. empty/missing <schemas> value in the user definition).","commonSituations":"Hand-edited server.xml where the user entry was added without a schemas attribute; whitespace-only or empty schemas value; migration between MyCat versions where schema references were renamed; copy-pasted user blocks with the schemas line deleted.","solutions":["Add the schemas attribute to the user element in server.xml, e.g. <user name=\"root\"><property name=\"schemas\">testdb</property></user>","Ensure the schema name referenced matches a <schema name=\"...\"> entry in schema.xml exactly (case-sensitive).","If multiple schemas are needed, list them comma-separated in the schemas property.","Remove the user entry entirely if it is not needed."],"exampleFix":"// before (server.xml)\n<user name=\"root\">\n  <property name=\"password\">123456</property>\n</user>\n// after\n<user name=\"root\">\n  <property name=\"password\">123456</property>\n  <property name=\"schemas\">testdb</property>\n</user>","handlingStrategy":"validation","validationCode":"// Before reload, parse server.xml and check each user has non-empty schemas\nfor (UserConfig uc : users.values()) {\n    if (uc.getSchemas() == null || uc.getSchemas().isEmpty()) {\n        throw new IllegalArgumentException(\"user \" + uc.getName() + \" has no schemas\");\n    }\n}","typeGuard":"boolean hasSchemas(UserConfig uc) { return uc != null && uc.getSchemas() != null && !uc.getSchemas().isEmpty(); }","tryCatchPattern":"try {\n    new ConfigInitializer(...);\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"refered schemas is empty\")) {\n        LOGGER.error(\"User missing schemas in server.xml: {}\", e.getMessage());\n        // fall back to last-known-good config\n    } else { throw e; }\n}","preventionTips":["Always include a schemas property in every <user> element in server.xml.","Validate server.xml and schema.xml together in CI before deploying.","Keep a known-good config copy for rollback.","After edits, grep server.xml user blocks for missing schemas attributes."],"tags":["config","startup","mycat","schema"],"backgroundTag":"empty-required-field","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}