MyCATApache/Mycat-Server · error · IllegalArgumentException

name is null

Error message

name is null

What it means

TableRuleConfig's constructor requires a non-null name for the table rule; if name is null it throws IllegalArgumentException("name is null"). The name is how <table> elements reference the rule via their rule attribute, so it must be present. (A subsequent check also rejects a null RuleConfig.)

Solutions

  1. Add name="<ruleName>" to the <tableRule> element in rule.xml.
  2. Ensure the name matches the rule attribute used by tables in schema.xml.
  3. If constructing programmatically, pass a non-null name string.

Example fix

// before (rule.xml)
<tableRule><rule><columns>id</columns><function>mod-long</function></rule></tableRule>
// after
<tableRule name="order-rule"><rule><columns>id</columns><function>mod-long</function></rule></tableRule>
Defensive patterns

Strategy: validation

Validate before calling

if (ruleName == null || ruleName.isEmpty()) throw new IllegalArgumentException("tableRule name attribute required");

Try / catch

try { new TableRuleConfig(name, rule); } catch (IllegalArgumentException e) { if ("name is null".equals(e.getMessage())) { LOG.error("tableRule missing name attr"); } throw e; }

Prevention

When it happens

Trigger: new TableRuleConfig(null, rule) or rule.xml parsing where a <tableRule> element has no name attribute.

Common situations: rule.xml tableRule element missing the name attribute; programmatic construction with null name; XML attribute loading failure returning null.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/config/model/rule/TableRuleConfig.java:37

 * 
 * Any questions about this component can be directed to it's project Web address 
 * https://code.google.com/p/opencloudb/.
 *
 */
package io.mycat.config.model.rule;

import java.io.Serializable;

/**
 * @author mycat
 */
public class TableRuleConfig implements Serializable {
    private  String name;
    private final RuleConfig rule;

    public TableRuleConfig(String name, RuleConfig rule) {
        if (name == null) {
            throw new IllegalArgumentException("name is null");
        }
        this.name = name;
        if (rule == null) {
            throw new IllegalArgumentException("no rule is found");
        }
        this.rule =rule;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return unmodifiable

View on GitHub (pinned to 65f8d8beb7)