MyCATApache/Mycat-Server · error · ConfigException

ConfigException wrapping cause (no message)

Error message

ConfigException wrapping cause (no message)

What it means

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.

Solutions

  1. Inspect the exception's cause / stack trace (getCause()) for the real error
  2. Validate rule.xml syntax and DTD conformance
  3. Check that every function class attribute names an existing class on the classpath with a usable constructor
  4. Compare rule.xml against a known-good copy from the same Mycat version
Defensive patterns

Strategy: try-catch

Validate before calling

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.parse(new File("rule.xml")); // fails fast on malformed rule.xml

Try / catch

try {
    new XMLRuleLoader();
} catch (ConfigException e) {
    if (e.getMessage() == null && e.getCause() != null) {
        log.error("rule.xml load failed", e.getCause()); // real error is in the cause
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: Typo in function class name after upgrading Mycat; broken XML syntax; custom partitioner class not on classpath; rule.xml referencing undefined algorithm properties.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/0dc42140fcfabdac. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java:95

	
	private void load(String dtdFile, String xmlFile) {
		InputStream dtd = null;
		InputStream xml = null;
		try {
			dtd = XMLRuleLoader.class.getResourceAsStream(dtdFile);
			xml = XMLRuleLoader.class.getResourceAsStream(xmlFile);
			//读取出语意树
			Element root = ConfigUtil.getDocument(dtd, xml)
					.getDocumentElement();
			//加载Function
			loadFunctions(root);
			//加载TableRule
			loadTableRules(root);
		} catch (ConfigException e) {
			throw e;
		} catch (Exception e) {
			throw new ConfigException(e);
		} finally {
			if (dtd != null) {
				try {
					dtd.close();
				} catch (IOException e) {
				}
			}
			if (xml != null) {
				try {
					xml.close();
				} catch (IOException e) {
				}
			}
		}
	}

	/**
	 * tableRule标签结构:

View on GitHub (pinned to 65f8d8beb7)