languagetool-org/languagetool · critical · RuntimeException
Could not load coherency data from " + path
Error message
Could not load coherency data from " + path
What it means
WordCoherencyDataLoader.loadWords wraps any IOException raised while reading the coherency data file in this RuntimeException, keeping the original as cause. It signals the coherency data at 'path' could not be read at all (missing file, unreadable, I/O failure), as opposed to a single bad line.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java:66
continue;
}
String[] parts = line.split(";");
if (parts.length != 2) {
throw new IOException("Format error in file " + path + ", line: " + line);
}
if(map.containsKey(parts[0])) {
map.get(parts[0]).add(parts[1]);
} else {
map.put(parts[0], Stream.of(parts[1]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));
}
if(map.containsKey(parts[1])) {
map.get(parts[1]).add(parts[0]);
} else {
map.put(parts[1], Stream.of(parts[0]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));
}
}
} catch (IOException e) {
throw new RuntimeException("Could not load coherency data from " + path, e);
}
return Collections.unmodifiableMap(map);
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Check the cause (getCause()) for the underlying IOException — usually FileNotFoundException.
- Verify the resource path exists on the classpath / filesystem for the given language.
- Ensure the data file is included in the build/packaging and readable at runtime.
Example fix
// before
loader.loadWords("/en/coherency.txt", language);
// after: verify resource exists first
if (getClass().getResource("/en/coherency.txt") == null) throw new IllegalStateException("coherency data missing");
loader.loadWords("/en/coherency.txt", language); Defensive patterns
Strategy: try-catch
Validate before calling
// verify resource exists before loading
if (getClass().getResource(path) == null)
throw new IllegalStateException("Coherency data not on classpath: " + path); Try / catch
try {
loader.loadWords(path, language);
} catch (RuntimeException e) {
// inspect e.getCause() for the underlying IOException
throw new IllegalStateException("Cannot read coherency data " + path, e);
} Prevention
- Always inspect getCause() for the root IOException
- Verify data files are packaged in the jar
- Check file permissions in deployment environments
When it happens
Trigger: loadFromPath pointing at a non-existent or unreadable coherency data file; disk I/O error while BufferedReader reads the stream; resource path missing from the language's jar.
Common situations: Wrong language resource path in rule construction; file not packaged into the jar after renaming; permission issues in deployment environments.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Could not tag and disambiguate '" + token + "'
- Could not tag and disambiguate '<token>'
- Could not tag and disambiguate '<token>'
- Could not load properties from ''
- Could not get rules of language <language>
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/1008e2f8b7403e94.
Report an issue: GitHub.