languagetool-org/languagetool · error · IOException
Could not load file from classpath: '${path}'
Error message
Could not load file from classpath: '${path}' What it means
Tools.getStream failed to open the given path as a classpath resource via Class#getResourceAsStream; the resource is missing from the classpath or the path is malformed. Rules/resource files should instead go through ResourceDataBroker.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/tools/Tools.java:269
public static String getFullStackTrace(Throwable e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
}
/**
* Load a file from the classpath using {@link Class#getResourceAsStream(String)}.
* Please load files in the {@code rules} and {@code resource} directories with
* {@link org.languagetool.broker.ResourceDataBroker} instead.
*/
public static InputStream getStream(String path) throws IOException {
// the other ways to load the stream like
// "Tools.class.getClass().getResourceAsStream(filename)"
// don't work in a web context (using Grails):
InputStream is = JLanguageTool.getDataBroker().getAsStream(path);
if (is == null) {
throw new IOException("Could not load file from classpath: '" + path + "'");
}
return is;
}
public static InputStream getStream(String path, String requiredHash) throws IOException, NoSuchAlgorithmException {
byte[] data;
try (InputStream is = getStream(path)) {
data = is.readAllBytes();
}
MessageDigest md = MessageDigest.getInstance("SHA-256");
String computedHash = HexFormat.of().formatHex(md.digest(data));
if (!computedHash.equals(requiredHash)) {
throw new IOException("Checksum mismatch for the file '" + path + "': expected " + requiredHash + ", got " + computedHash);
}
return new ByteArrayInputStream(data);View on GitHub (pinned to 2e990059ce)
Solutions
- Check the path spelling and that the file is on the classpath
- Prefer ResourceDataBroker for files under rules/ or resource/
- Ensure the resource is packaged in the running jar/module
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tools/Tools.java:269 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/621b3fcdb70a8ca0.
Report an issue: GitHub.