{"record":{"id":"35a175a0f1e4e513","repo":"MyCATApache/Mycat-Server","slug":"old-config-for-migrate-read-fail-please-check-sch","errorCode":null,"errorMessage":" old config for migrate read fail!please check schema.xml or  rule.xml  {e}","messagePattern":" old config for migrate read fail!please check schema\\.xml or  rule\\.xml  (.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java","lineNumber":83,"sourceCode":"\tpublic ConfigComparer(boolean isAwaysUseMaster) throws Exception{\n\t\tthis.isAwaysUseMaster = isAwaysUseMaster;\n\t\tloadOldConfig();\n\t\tloadNewConfig();\n\t\tloadTablesFile();\n\t}\n\t\n\tpublic List<TableMigrateInfo> getMigratorTables(){\n\t\treturn migratorTables;\n\t}\n\t\n\tprivate void loadOldConfig(){\n\t\ttry{\n\t\t\toldLoader = new XMLSchemaLoader();\n\t\t\toldDataHosts = oldLoader.getDataHosts();\n\t\t\toldDataNodes = oldLoader.getDataNodes();\n\t\t\toldSchemas = oldLoader.getSchemas();\n\t\t}catch(Exception e){\n\t\t\tthrow new ConfigException(\" old config for migrate read fail!please check schema.xml or  rule.xml  \"+e);\n\t\t}\n\t\t\n\t}\n\t\n\tprivate void loadNewConfig(){\n\t\ttry{\n\t\t\tnewLoader = new XMLSchemaLoader(NEW_SCHEMA, NEW_RULE);\n\t\t\tnewDataHosts = newLoader.getDataHosts();\n\t\t\tnewDataNodes = newLoader.getDataNodes();\n\t\t\tnewSchemas = newLoader.getSchemas();\n\t\t}catch(Exception e){\n\t\t\tthrow new ConfigException(\" new config for migrate read fail!please check newSchema.xml or  newRule.xml  \"+e);\n\t\t}\n\t\t\n\t}\n\t\n\t\n\tprivate void loadTablesFile() throws Exception{","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java#L65-L101","documentation":"ConfigComparer.loadOldConfig loads the pre-migration sharding configuration using XMLSchemaLoader over the default schema.xml/rule.xml. Any parsing or validation failure in those XML files is wrapped as ConfigException(' old config for migrate read fail!please check schema.xml or rule.xml <cause>').","triggerScenarios":"Running the dataMigrator flow (MigrateRunner/ConfigComparer) when schema.xml or rule.xml is missing, malformed XML, references nonexistent dataHost/dataNode, or violates Mycat's schema rules.","commonSituations":"Old cluster configs copied incompletely to the migration working directory; hand-edited XML with unbalanced tags; DTD/xsd references broken; table/rule names mismatched between schema.xml and rule.xml.","solutions":["Open the wrapped cause in the message — it names the actual XML parse or validation failure","Validate schema.xml and rule.xml are present in the expected location and well-formed XML (xmllint)","Ensure every <table> rule reference exists in rule.xml and all dataNode/dataHost names resolve","Run the migration with a config known to work: start Mycat normally first to confirm the old config loads"],"exampleFix":"// before\n<!-- rule.xml missing rule=\"mod-rule\" referenced by schema.xml -->\n// after\nadd <tableRule name=\"mod-rule\"> ... </tableRule> to rule.xml","handlingStrategy":"validation","validationCode":"static boolean oldConfigReadable(String schemaXml, String ruleXml){\n    try {\n        javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new java.io.File(schemaXml));\n        javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new java.io.File(ruleXml));\n        return true;\n    } catch (Exception e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { comparer.loadOldConfig(); }\ncatch (ConfigException e) { LOG.error(\"old schema.xml/rule.xml unreadable: \" + e.getMessage(), e); throw e; }","preventionTips":["Lint schema.xml and rule.xml (xmllint) before running migration","Verify every referenced rule/dataNode/dataHost exists in the pair of files","Keep old configs in version control so migrations use known-good copies","Boot Mycat with the same config first to prove it loads"],"tags":["xml","configuration","migration","mycat"],"backgroundTag":"file-read-failed","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"}