MyCATApache/Mycat-Server · error · io.mycat.config.ConfigException

SelfCheck### user refered schemas is empty!

Error message

SelfCheck### user {name}refered schemas is empty!

What it means

Thrown by MyCat's ConfigInitializer during startup self-check (selfChecking0) when a user entry in the users config node has a null schemas set. MyCat requires every configured user to reference at least one logical schema for authorization, so a user without schemas makes the config invalid and startup is aborted with ConfigException.

Solutions

  1. Add the schemas attribute to the user element in server.xml, e.g. <user name="root"><property name="schemas">testdb</property></user>
  2. Ensure the schema name referenced matches a <schema name="..."> entry in schema.xml exactly (case-sensitive).
  3. If multiple schemas are needed, list them comma-separated in the schemas property.
  4. Remove the user entry entirely if it is not needed.

Example fix

// before (server.xml)
<user name="root">
  <property name="password">123456</property>
</user>
// after
<user name="root">
  <property name="password">123456</property>
  <property name="schemas">testdb</property>
</user>
Defensive patterns

Strategy: validation

Validate before calling

// Before reload, parse server.xml and check each user has non-empty schemas
for (UserConfig uc : users.values()) {
    if (uc.getSchemas() == null || uc.getSchemas().isEmpty()) {
        throw new IllegalArgumentException("user " + uc.getName() + " has no schemas");
    }
}

Type guard

boolean hasSchemas(UserConfig uc) { return uc != null && uc.getSchemas() != null && !uc.getSchemas().isEmpty(); }

Try / catch

try {
    new ConfigInitializer(...);
} catch (ConfigException e) {
    if (e.getMessage().contains("refered schemas is empty")) {
        LOGGER.error("User missing schemas in server.xml: {}", e.getMessage());
        // fall back to last-known-good config
    } else { throw e; }
}

Prevention

When it happens

Trigger: Booting or reloading MyCat (ConfigInitializer constructor) with a server.xml user element that has no schemas attribute, or a UserConfig whose getSchemas() returns null (e.g. empty/missing <schemas> value in the user definition).

Common situations: Hand-edited server.xml where the user entry was added without a schemas attribute; whitespace-only or empty schemas value; migration between MyCat versions where schema references were renamed; copy-pasted user blocks with the schemas line deleted.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/config/ConfigInitializer.java:136

		this.selfChecking0();
	}
	
	private void selfChecking0() throws ConfigException {
		
		// 检查user与schema配置对应以及schema配置不为空
		if (users == null || users.isEmpty()) {
			throw new ConfigException("SelfCheck### user all node is empty!");
			
		} else {
			
			for (UserConfig uc : users.values()) {
				if (uc == null) {
					throw new ConfigException("SelfCheck### users node within the item is empty!");
				}
				
				Set<String> authSchemas = uc.getSchemas();
				if (authSchemas == null) {
					throw new ConfigException("SelfCheck### user " + uc.getName() + "refered schemas is empty!");
				}
				
				for (String schema : authSchemas) {
					if ( !schemas.containsKey(schema) ) {
						String errMsg = "SelfCheck###  schema " + schema + " refered by user " + uc.getName() + " is not exist!";
						throw new ConfigException(errMsg);
					}
				}
			}
		}	
		
		
		// schema 配置检测		
		for (SchemaConfig sc : schemas.values()) {
			if (null == sc) {
				throw new ConfigException("SelfCheck### schema all node is empty!");
				
			} else {				

View on GitHub (pinned to 65f8d8beb7)