MyCATApache/Mycat-Server · error · IllegalArgumentException
no rule is found
Error message
no rule is found
What it means
TableRuleConfig's constructor throws IllegalArgumentException when the RuleConfig argument is null. The library requires every named table rule to have a non-null rule object, so a null rule is rejected immediately at construction time. This fails fast rather than allowing a half-initialized table rule to break routing later.
Solutions
- Check that the RuleConfig passed to the constructor is non-null before constructing TableRuleConfig
- Verify the rule referenced in schema.xml exists and was successfully parsed from rule.xml
- Fix any earlier load failure (check logs/warnings during rule loading) that left the RuleConfig null
Example fix
// before
TableRuleConfig trc = new TableRuleConfig("order", ruleMap.get("orderRule")); // null if key missing
// after
RuleConfig rc = ruleMap.get("orderRule");
if (rc == null) { throw new ConfigException("rule 'orderRule' not defined in rule.xml"); }
TableRuleConfig trc = new TableRuleConfig("order", rc); Defensive patterns
Strategy: validation
Validate before calling
if (rule == null) { throw new ConfigException("table '" + name + "' has no matching rule; check rule.xml"); }
TableRuleConfig trc = new TableRuleConfig(name, rule); Try / catch
try { new TableRuleConfig(name, rule); } catch (IllegalArgumentException e) { log.error("bad table rule: {}", e.getMessage()); throw e; } Prevention
- Always resolve RuleConfig from the parsed rule map and assert non-null before construction
- Fail fast at config load with a message naming the missing rule
- Add a startup self-check that every <table> rule reference resolves
When it happens
Trigger: Calling new TableRuleConfig(name, null) — e.g. when building a table rule programmatically or when config parsing produced a RuleConfig object that was null but a name was present.
Common situations: schema.xml / rule.xml misconfiguration where a <table> references a rule name that failed to load; initialization code passing an uninitialized RuleConfig; unit tests constructing rules manually.
Related errors
- rule is not found!
- Illegal table conf : table
- in noSharding mode schema must have default dataNode
- table name is null
- dataNode name is null
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/8313c60bf2eb10bd.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/config/model/rule/TableRuleConfig.java:41
*/
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
*/
public RuleConfig getRule() {
return rule;
}View on GitHub (pinned to 65f8d8beb7)