MyCATApache/Mycat-Server · error · ConfigException

please check file "dnindex.properties

Error message

please check file "dnindex.properties" {e}

What it means

loadDnIndexProps reads dnindex.properties from the classpath; this file records which data node index each node previously held, needed to map data during migration. Any failure loading it (missing resource, null stream, IO error) is wrapped in a ConfigException whose message includes the underlying exception text, telling the user to check the file.

Solutions

  1. Ensure dnindex.properties exists in the conf directory and that directory is on the classpath.
  2. Read the appended underlying message (e.getMessage()) to identify the exact cause (null stream vs IO error).
  3. If migrating from scratch without prior data node layout, generate or provide an empty/valid dnindex.properties.
  4. Restore the file from backup if it was deleted after a previous migration.

Example fix

// before
java -cp mycat.jar ...DataMigrator   # dnindex.properties missing
// after
java -cp mycat.jar:conf ...DataMigrator   # conf/dnindex.properties present
Defensive patterns

Strategy: validation

Validate before calling

String res = "/dnindex.properties";
if (ConfigComparer.class.getResource(res) == null) {
    throw new IllegalStateException("dnindex.properties missing from classpath");
}
try (InputStream in = ConfigComparer.class.getResourceAsStream(res)) {
    new Properties().load(in); // fail fast with real cause
}

Try / catch

try {
    comparer.compare();
} catch (ConfigException e) {
    if (e.getMessage().contains("dnindex.properties")) {
        // inspect appended cause; restore file to conf/ and ensure it is on -cp
    }
    throw e;
}

Prevention

When it happens

Trigger: dnindex.properties absent from the classpath; getResourceAsStream returns null so prop.load(null) throws NullPointerException; file unreadable or malformed.

Common situations: Fresh deployment where dnindex.properties was never generated; file deleted between migrations; launching the migrator without the directory containing dnindex.properties on the classpath.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java:259

		if(!oldRC.getColumn().equalsIgnoreCase(newRC.getColumn())){
			throw new ConfigException(schemaName+":"+tableName+" old & new partition column is not same!");
		}
		AbstractPartitionAlgorithm oldAlg = oldRC.getRuleAlgorithm();
		AbstractPartitionAlgorithm newAlg = newRC.getRuleAlgorithm();
		//判断路由算法前后是否一致
		if(!oldAlg.getClass().isAssignableFrom(newAlg.getClass())){
			throw new ConfigException(schemaName+":"+tableName+" old & new rule Algorithm is not same!");
		}
	}
	
	private Properties loadDnIndexProps() {
		Properties prop = new Properties();
		InputStream is = null;
		try {
			is = ConfigComparer.class.getResourceAsStream(DN_INDEX_FILE);
			prop.load(is);
		} catch (Exception e) {
			throw new ConfigException("please check file \"dnindex.properties\" "+e.getMessage());
		} finally {
			try {
				if(is !=null){
					is.close();
				}
			} catch (IOException e) {
				throw new ConfigException(e.getMessage());
			}
		}
		return prop;
	}
}

View on GitHub (pinned to 65f8d8beb7)