{"record":{"id":"0dc42140fcfabdac","repo":"MyCATApache/Mycat-Server","slug":"configexception-wrapping-cause-no-message","errorCode":null,"errorMessage":"ConfigException wrapping cause (no message)","messagePattern":"ConfigException wrapping cause \\(no message\\)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java","lineNumber":95,"sourceCode":"\r\n\t\r\n\tprivate void load(String dtdFile, String xmlFile) {\r\n\t\tInputStream dtd = null;\r\n\t\tInputStream xml = null;\r\n\t\ttry {\r\n\t\t\tdtd = XMLRuleLoader.class.getResourceAsStream(dtdFile);\r\n\t\t\txml = XMLRuleLoader.class.getResourceAsStream(xmlFile);\r\n\t\t\t//读取出语意树\r\n\t\t\tElement root = ConfigUtil.getDocument(dtd, xml)\r\n\t\t\t\t\t.getDocumentElement();\r\n\t\t\t//加载Function\r\n\t\t\tloadFunctions(root);\r\n\t\t\t//加载TableRule\r\n\t\t\tloadTableRules(root);\r\n\t\t} catch (ConfigException e) {\r\n\t\t\tthrow e;\r\n\t\t} catch (Exception e) {\r\n\t\t\tthrow new ConfigException(e);\r\n\t\t} finally {\r\n\t\t\tif (dtd != null) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tdtd.close();\r\n\t\t\t\t} catch (IOException e) {\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (xml != null) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\txml.close();\r\n\t\t\t\t} catch (IOException e) {\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * tableRule标签结构：\r","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java#L77-L113","documentation":"XMLRuleLoader.load parses rule.xml and calls loadFunctions/loadTableRules; ConfigException is rethrown as-is, but any other Exception (XML parse errors, DTD issues, reflection failures instantiating functions, ClassNotFound) is wrapped in new ConfigException(e), producing an exception with no message of its own — the cause carries the real error.","triggerScenarios":"Malformed rule.xml or DTD fetch failure; a <function> element naming a class that does not exist or lacks the expected constructor; any runtime error during function/table-rule loading.","commonSituations":"Typo in function class name after upgrading Mycat; broken XML syntax; custom partitioner class not on classpath; rule.xml referencing undefined algorithm properties.","solutions":["Inspect the exception's cause / stack trace (getCause()) for the real error","Validate rule.xml syntax and DTD conformance","Check that every function class attribute names an existing class on the classpath with a usable constructor","Compare rule.xml against a known-good copy from the same Mycat version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\ndbf.setValidating(true);\ndbf.parse(new File(\"rule.xml\")); // fails fast on malformed rule.xml","typeGuard":null,"tryCatchPattern":"try {\n    new XMLRuleLoader();\n} catch (ConfigException e) {\n    if (e.getMessage() == null && e.getCause() != null) {\n        log.error(\"rule.xml load failed\", e.getCause()); // real error is in the cause\n    }\n}","preventionTips":["Always log the full stack trace, not just getMessage(), for ConfigException","Validate rule.xml against the DTD in CI before deploy","Keep the partitioning function classes on the classpath and spelled exactly as in rule.xml","Diff rule.xml against the shipped example for your Mycat version after upgrades"],"tags":["config","xml","rule-loader","wrapped-exception"],"backgroundTag":"missing-config-file","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"}