{"record":{"id":"349f16523675b425","repo":"MyCATApache/Mycat-Server","slug":"configexception-wrapping-cause-no-message-349f16","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/XMLSchemaLoader.java","lineNumber":121,"sourceCode":"    }\n\n    private void load(String dtdFile, String xmlFile) {\n        InputStream dtd = null;\n        InputStream xml = null;\n        try {\n            dtd = XMLSchemaLoader.class.getResourceAsStream(dtdFile);\n            xml = XMLSchemaLoader.class.getResourceAsStream(xmlFile);\n            Element root = ConfigUtil.getDocument(dtd, xml).getDocumentElement();\n            //先加载所有的DataHost\n            loadDataHosts(root);\n            //再加载所有的DataNode\n            loadDataNodes(root);\n            //最后加载所有的Schema\n            loadSchemas(root);\n        } catch (ConfigException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new ConfigException(e);\n        } finally {\n\n            if (dtd != null) {\n                try {\n                    dtd.close();\n                } catch (IOException e) {\n                }\n            }\n\n            if (xml != null) {\n                try {\n                    xml.close();\n                } catch (IOException e) {\n                }\n            }\n        }\n    }\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java#L103-L139","documentation":"XMLSchemaLoader.load catches any non-ConfigException thrown while parsing schema.xml (loadDataHosts, loadDataNodes, loadSchemas) and wraps it in a ConfigException with the original as cause and no message of its own. The real failure reason (XML parse error, NPE, IO problem, DTD issue) is only visible in the wrapped cause's stack trace.","triggerScenarios":"Any unexpected Exception during XMLSchemaLoader construction: malformed XML, missing required child elements causing NPE inside loadSchemas/loadTables/loadDataNodes, IO errors, ClassCastException; load() rethrows as cause-less-message ConfigException.","commonSituations":"schema.xml edited with a broken tag or wrong DTD; element attributes missing (getAttribute returning empty string leading to downstream NPE); file encoding problems; upgrades where the DTD no longer matches the XML.","solutions":["Read the full stack trace's 'Caused by' section to find the underlying exception and its line.","Validate schema.xml against its DTD (xmllint --dtdvalid) and fix structural errors.","Temporarily add logging or run in a debugger to find which load* method throws before the wrap point.","Restore a known-good schema.xml and reapply changes incrementally to isolate the offending element."],"exampleFix":"// before (schema.xml)\n<schema name=\"TESTDB\">\n  <table name=\"orders\" dataNode=\"dn1\" />\n<!-- missing closing </schema> -->\n// after\n<schema name=\"TESTDB\">\n  <table name=\"orders\" dataNode=\"dn1\" />\n</schema>","handlingStrategy":"try-catch","validationCode":"// Validate schema.xml structure before startup\nDocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();\ndb.setErrorHandler(new DefaultHandler() {\n    @Override public void error(SAXParseException e) throws SAXException { throw e; }\n});\ndb.parse(new File(\"schema.xml\")); // throws on malformed XML before MyCat load","typeGuard":null,"tryCatchPattern":"try {\n    loader = new XMLSchemaLoader();\n} catch (ConfigException e) {\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause(); // unwrap to real reason\n    LOG.error(\"schema.xml load failed, root cause:\", root);\n    throw new IllegalArgumentException(\"Invalid schema.xml: \" + root.getMessage(), e);\n}","preventionTips":["Always inspect the 'Caused by' chain; the wrapper carries no message.","Validate schema.xml against its DTD in CI (xmllint --dtdvalid).","Change schema.xml incrementally so the failing edit is easy to isolate.","Keep a known-good backup of schema.xml."],"tags":["configuration","xml","wrapped-exception","parsing"],"backgroundTag":"schema-validation-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"}