MyCATApache/Mycat-Server · error · ConfigException
[user: ] doesn't exist in [host: ]
Error message
[user: ${user}] doesn't exist in [host: ${hostStr}] What it means
In loadFirewall, every user named in a <host user="..."> whitelist entry must already exist in the <user> section of server.xml. XMLServerLoader looks the user up in its users map and throws this ConfigException if it is null — i.e., the firewall references a user that was never defined or whose definition failed to load.
Solutions
- Add the missing <user name="..."> definition to server.xml, or correct the spelling in the firewall's user attribute to match an existing user
- Remove stale firewall user references for users that were intentionally deleted
- Grep server.xml to cross-check every user listed in <firewall> against defined <user> names before deploying
- Restart MyCat and verify the server.xml loads
Example fix
// before <user name="alice">...</user> removed, but firewall has: <host host="10.0.0.1" user="alice"/> // after <host host="10.0.0.1" user="bob"/> <!-- or re-add the alice <user> definition -->
Defensive patterns
Strategy: validation
Validate before calling
// verify firewall users exist in the <user> section
Set<String> defined = new HashSet<>();
NodeList us = doc.getElementsByTagName("user");
for (int i = 0; i < us.getLength(); i++)
defined.add(((Element) us.item(i)).getAttribute("name"));
for each firewall host element:
for (String u : e.getAttribute("user").split(","))
if (!defined.contains(u.trim())) throw new IllegalStateException("Firewall references unknown user: " + u); Type guard
null
Try / catch
try {
serverLoader.load();
} catch (ConfigException e) {
LOG.error("Firewall references undefined user: " + e.getMessage());
throw new ConfigurationException("Define the user or fix the firewall entry", e);
} Prevention
- When renaming/deleting users, grep server.xml for all references including firewall entries
- Keep a single source of truth for user definitions across environments
- Validate user references in CI before deploying server.xml
When it happens
Trigger: server.xml contains <host host="..." user="alice"> but no <user name="alice"> element exists (or it is misspelled / commented out); firewall section is parsed after users are loaded, so the lookup misses.
Common situations: Renaming a user in the <user> section but not in the firewall whitelist; typo in the user attribute; deleting a user while leaving stale firewall entries; environment-specific overlays where users differ per env.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- host duplicated
- [host: ] contains one root privileges user
- CachePoolFactory not defined for type
- can't find cache pool
- SelfCheck### user all node is empty!
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/47a789756849868c.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java:161
Node node = list.item(i);
if (node instanceof Element) {
Element e = (Element) node;
String hostStr = e.getAttribute("host").trim();
String userStr = e.getAttribute("user").trim();
String []hosts = hostStr.split(",");
for (String host : hosts) {
host = host.trim();
if (this.firewall.existsHost(host)) {
throw new ConfigException("host duplicated : " + host);
}
}
String []users = userStr.split(",");
List<UserConfig> userConfigs = new ArrayList<UserConfig>();
for(String user : users){
user = user.trim();
UserConfig uc = this.users.get(user);
if (null == uc) {
throw new ConfigException("[user: " + user + "] doesn't exist in [host: " + hostStr + "]");
}
if (uc.getSchemas() == null || uc.getSchemas().size() == 0) {
throw new ConfigException("[host: " + hostStr + "] contains one root privileges user: " + user);
}
userConfigs.add(uc);
}
for (String host : hosts) {
host = host.trim();
if (host.contains("*") || host.contains("%")) {
whitehostMask.put(FirewallConfig.getMaskPattern(host), userConfigs);
} else {
whitehost.put(host, userConfigs);
}
}
}
}
firewall.setWhitehost(whitehost);View on GitHub (pinned to 65f8d8beb7)