MyCATApache/Mycat-Server · error · ConfigException

table name is not found!

Error message

table name is not found!

What it means

Thrown by XMLSchemaLoader.loadTable when a <table> element in schema.xml has no 'name' attribute (tableNames parsed to null/empty). Mycat cannot register a table without a name, so schema loading fails fast with ConfigException.

Solutions

  1. Add a non-empty name attribute to the offending <table> element in schema.xml
  2. Validate schema.xml structure (every table needs name, dataNode, and optionally rule)
  3. If multiple names, use comma-separated names in the name attribute

Example fix

// before (schema.xml)
<table dataNode="dn1" rule="rule1" />
// after
<table name="orders" dataNode="dn1" rule="rule1" />
Defensive patterns

Strategy: validation

Validate before calling

// ensure every <table> has a non-empty name before loading
for (Element t : schemaTables("schema.xml")) {
    if (!t.hasAttribute("name") || t.getAttribute("name").trim().isEmpty())
        throw new IllegalStateException("<table> missing name attribute");
}

Try / catch

try {
    configLoader.load();
} catch (ConfigException e) {
    if ("table name is not found!".equals(e.getMessage())) {
        log.error("A <table> element in schema.xml has no name attribute", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A <table dataNode="dn1" ...> element missing the name attribute entirely, or name="" empty in schema.xml, reached via loadTables from the schema loader.

Common situations: Hand-edited schema.xml where the name attribute was accidentally deleted; XML minification tools dropping attributes; generated configs with empty placeholders.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java:378

            //记录dataNode,就是分布在哪些dataNode上
            String dataNode = tableElement.getAttribute("dataNode");
            TableRuleConfig tableRule = null;
            if (tableElement.hasAttribute("rule")) {
                String ruleName = tableElement.getAttribute("rule");
                tableRule = tableRules.get(ruleName);
                if (tableRule == null) {
                    throw new ConfigException("rule " + ruleName + " is not found!");
                }
            }

            boolean ruleRequired = false;
            //记录是否绑定有分片规则
            if (tableElement.hasAttribute("ruleRequired")) {
                ruleRequired = Boolean.parseBoolean(tableElement.getAttribute("ruleRequired"));
            }

            if (tableNames == null) {
                throw new ConfigException("table name is not found!");
            }
            //distribute函数,重新编排dataNode
            String distPrex = "distribute(";
            boolean distTableDns = dataNode.startsWith(distPrex);
            if (distTableDns) {
                dataNode = dataNode.substring(distPrex.length(), dataNode.length() - 1);
            }
            //分表功能
            String subTables = tableElement.getAttribute("subTables");

            for (int j = 0; j < tableNames.length; j++) {

                String tableName = tableNames[j];
                TableRuleConfig tableRuleConfig = tableRule;
                if (tableRuleConfig != null) {
                    //对于实现TableRuleAware的function进行特殊处理  根据每个表新建个实例
                    RuleConfig rule = tableRuleConfig.getRule();
                    if (rule.getRuleAlgorithm() instanceof TableRuleAware) {

View on GitHub (pinned to 65f8d8beb7)