{"record":{"id":"76e9a099affd9667","repo":"languagetool-org/languagetool","slug":"could-not-activate-rules","errorCode":null,"errorMessage":"Could not activate rules","messagePattern":"Could not activate rules","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"languagetool-core/src/main/java/org/languagetool/JLanguageTool.java","lineNumber":364,"sourceCode":"    this.userConfig = Objects.requireNonNullElseGet(userConfig, UserConfig::new);\n    this.globalConfig = globalConfig;\n    this.cleanOverlappingMatches = true;\n    ResourceBundle messages = ResourceBundleTools.getMessageBundle(language);\n    if (customRules != null) {\n      builtinRules = new ArrayList<>(customRules);\n    } else {\n      builtinRules = getAllBuiltinRules(language, messages, userConfig, globalConfig);\n      try {\n        activateDefaultPatternRules();\n        if (!language.hasNGramFalseFriendRule(motherTongue)) {\n          // use the old false friends, which always match, not depending on context\n          activateDefaultFalseFriendRules();\n        }\n        if (!withLanguageModel) {\n          updateOptionalLanguageModelRules(null); // start out with rules without language model\n        }\n      } catch (Exception e) {\n        throw new RuntimeException(\"Could not activate rules\", e);\n      }\n    }\n    this.cache = cache;\n    descProvider = new ShortDescriptionProvider();\n    this.inputLogging = inputLogging;\n  }\n\n  /**\n   * Create a JLanguageTool and setup the built-in rules for the\n   * given language and false friend rules for the text language / mother tongue pair.\n   *\n   * @param language     the language of the text to be checked\n   * @param motherTongue the user's mother tongue, used for false friend rules, or <code>null</code>.\n   *                     The mother tongue may also be used as a source language for checking bilingual texts.\n   * @param cache        a cache to speed up checking if the same sentences get checked more than once,\n   *                     e.g. when LT is running as a server and texts are re-checked due to changes\n   * @since 4.2\n   */","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/JLanguageTool.java#L346-L382","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nJLanguageTool lt = new JLanguageTool(new MyCustomLanguage());\n// after (verify builtin rules load cleanly first)\nJLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode(\"en-US\"));","handlingStrategy":"try-catch","validationCode":"try {\n  Language lang = Languages.getLanguageForShortCode(code);\n  // smoke-test instance creation at startup, not on first request\n  try (JLanguageTool lt = new JLanguageTool(lang)) { }\n} catch (RuntimeException e) {\n  throw new IllegalStateException(\"LanguageTool init failed: \" + e.getCause(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  lt = new JLanguageTool(language);\n} catch (RuntimeException e) {\n  logger.error(\"Rule activation failed\", e.getCause());\n  throw e; // instance is unusable; fail fast\n}","preventionTips":["Create instances at startup to surface init failures early.","Keep jar versions consistent across core and language modules.","Verify distribution integrity after deployment."],"tags":["initialization","rules","constructor","runtime-exception"],"backgroundTag":"module-init-failed","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}