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
- Add name="<ruleName>" to the <tableRule> element in rule.xml.
- Ensure the name matches the rule attribute used by tables in schema.xml.
- 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
- Every <tableRule> in rule.xml needs a unique name attribute.
- Ensure schema.xml rule attributes reference these names exactly.
- Validate rule.xml before startup and in CI.
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
- functionName is null
- table name is null
- dataNode name is null
- ruleRequired but rule is null
- no rule column is found
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 unmodifiableView on GitHub (pinned to 65f8d8beb7)