languagetool-org/languagetool · critical · RuntimeException
Could not activate rules
Error message
Could not activate rules
What it means
The JLanguageTool constructor loads and activates the language's builtin rules (pattern rules, false friends, optional language-model rules). Any Exception during that setup is rethrown as this RuntimeException, so an instance could not be fully initialized with its rules.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/JLanguageTool.java:364
this.userConfig = Objects.requireNonNullElseGet(userConfig, UserConfig::new);
this.globalConfig = globalConfig;
this.cleanOverlappingMatches = true;
ResourceBundle messages = ResourceBundleTools.getMessageBundle(language);
if (customRules != null) {
builtinRules = new ArrayList<>(customRules);
} else {
builtinRules = getAllBuiltinRules(language, messages, userConfig, globalConfig);
try {
activateDefaultPatternRules();
if (!language.hasNGramFalseFriendRule(motherTongue)) {
// use the old false friends, which always match, not depending on context
activateDefaultFalseFriendRules();
}
if (!withLanguageModel) {
updateOptionalLanguageModelRules(null); // start out with rules without language model
}
} catch (Exception e) {
throw new RuntimeException("Could not activate rules", e);
}
}
this.cache = cache;
descProvider = new ShortDescriptionProvider();
this.inputLogging = inputLogging;
}
/**
* Create a JLanguageTool and setup the built-in rules for the
* given language and false friend rules for the text language / mother tongue pair.
*
* @param language the language of the text to be checked
* @param motherTongue the user's mother tongue, used for false friend rules, or <code>null</code>.
* The mother tongue may also be used as a source language for checking bilingual texts.
* @param cache a cache to speed up checking if the same sentences get checked more than once,
* e.g. when LT is running as a server and texts are re-checked due to changes
* @since 4.2
*/View on GitHub (pinned to 2e990059ce)
Solutions
- Inspect the 'Caused by' chain — it names the rule/resource that failed to load.
- Verify all LanguageTool jars are the same version (no mixed core/language-module versions).
- Re-download/rebuild the distribution to restore corrupted rule XML resources.
- If a custom Language/Rules implementation is involved, test getRelevantRules() in isolation.
Example fix
// before
JLanguageTool lt = new JLanguageTool(new MyCustomLanguage());
// after (verify builtin rules load cleanly first)
JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("en-US")); Defensive patterns
Strategy: try-catch
Validate before calling
try {
Language lang = Languages.getLanguageForShortCode(code);
// smoke-test instance creation at startup, not on first request
try (JLanguageTool lt = new JLanguageTool(lang)) { }
} catch (RuntimeException e) {
throw new IllegalStateException("LanguageTool init failed: " + e.getCause(), e);
} Try / catch
try {
lt = new JLanguageTool(language);
} catch (RuntimeException e) {
logger.error("Rule activation failed", e.getCause());
throw e; // instance is unusable; fail fast
} Prevention
- Create instances at startup to surface init failures early.
- Keep jar versions consistent across core and language modules.
- Verify distribution integrity after deployment.
When it happens
Trigger: Constructing new JLanguageTool(lang) (or with config/cache variants) when rule loading fails: broken XML grammar rules for the language, missing resource files, activateDefaultFalseFriendRules or updateOptionalLanguageModelRules throwing.
Common situations: Corrupted or partial languagetool-core resource deployment; a language module whose rule XML fails to parse; classpath issues after an upgrade leaving mixed jar versions; custom language implementations with faulty getRelevantRules.
Related errors
- Could not load language model capable rules.
- Could not create LanguageTool instance for language <languag
- Could not get rules of language <language>
- Could not check text in file <file>
- No rules are active. Please make sure your rule ids (<option
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/76e9a099affd9667.
Report an issue: GitHub.