languagetool-org/languagetool · error · RuntimeException
Could not get rules of language
Error message
Could not get rules of language <language>
What it means
getAllBuiltinRules asks the Language for its relevant rules via getRelevantRules and getRelevantRulesGlobalConfig; these can throw IOException while loading resources. Such an IOException is wrapped in this RuntimeException naming the language. It means the language's builtin rule set could not be retrieved.
Solutions
- Check the wrapped IOException's message for the missing/unreadable resource path.
- Verify the language module jar is complete and on the classpath (unzip -l to confirm rule XMLs).
- Run with a clean, matching-version set of LanguageTool artifacts (core + language modules).
- For custom languages, ensure resource streams are correctly packaged inside the jar.
Example fix
// before (custom language resource read from working dir)
InputStream s = new FileInputStream("rules.xml");
// after (package resource in jar and read via classloader)
InputStream s = getClass().getResourceAsStream("/org/languagetool/rules/rules.xml"); Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the language module jar contains its rule resources
URL res = getClass().getResource("/org/languagetool/rules/<lang>/grammar.xml");
if (res == null) throw new IllegalStateException("language rule resources missing from classpath"); Try / catch
try {
lt = new JLanguageTool(language);
} catch (RuntimeException e) {
if (e.getCause() instanceof IOException io) {
logger.error("Missing/unreadable rule resource for " + language + ": " + io.getMessage());
}
throw e;
} Prevention
- Check resource presence via classpath lookups before constructing instances.
- Avoid shading configs that strip language module resources.
- Verify file read permissions in deployment images.
When it happens
Trigger: Creating any JLanguageTool instance when the language's getRelevantRules(...) throws IOException — typically a missing or unreadable internal resource (rule XML, spelling dictionaries) for that language.
Common situations: Incomplete jar/classpath (language resources stripped by shading or packaging); read-permission problems on resource files; custom Language whose rule-loading code throws IOException.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not activate rules
- Could not load coherency data from " + path
- Could not load language model capable rules.
- Cannot activate rule '
- Cannot load or parse input stream of
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/dba9fa27116bae59.
Report an issue: GitHub.
Appendix: source
Thrown at languagetool-core/src/main/java/org/languagetool/JLanguageTool.java:527
return ResourceBundleTools.getMessageBundle();
}
/**
* Gets the ResourceBundle (i18n strings) for the given user interface language.
*
* @since 2.4 (public since 2.4)
*/
public static ResourceBundle getMessageBundle(Language lang) {
return ResourceBundleTools.getMessageBundle(lang);
}
private List<Rule> getAllBuiltinRules(Language language, ResourceBundle messages, UserConfig userConfig, GlobalConfig globalConfig) {
try {
List<Rule> rules = new ArrayList<>(language.getRelevantRules(messages, userConfig, motherTongue, altLanguages));
rules.addAll(language.getRelevantRulesGlobalConfig(messages, globalConfig, userConfig, motherTongue, altLanguages));
return rules;
} catch (IOException e) {
throw new RuntimeException("Could not get rules of language " + language, e);
}
}
/**
* Set a PrintStream that will receive verbose output. Set to
* {@code null} (which is the default) to disable verbose output.
*/
public void setOutput(PrintStream printStream) {
this.printStream = printStream;
GlobalConfig.setVerbose(printStream != null);
}
/**
* Load pattern rules from an XML file. Use {@link #addRule(Rule)} to add these
* rules to the checking process.
*
* @param filename path to an XML file in the classpath or in the filesystem - the classpath is checked first
* @return a List of {@link PatternRule} objectsView on GitHub (pinned to 2e990059ce)