{"record":{"id":"dba9fa27116bae59","repo":"languagetool-org/languagetool","slug":"could-not-get-rules-of-language-language","errorCode":null,"errorMessage":"Could not get rules of language <language>","messagePattern":"Could not get rules of language <language>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/JLanguageTool.java","lineNumber":527,"sourceCode":"    return ResourceBundleTools.getMessageBundle();\n  }\n\n  /**\n   * Gets the ResourceBundle (i18n strings) for the given user interface language.\n   *\n   * @since 2.4 (public since 2.4)\n   */\n  public static ResourceBundle getMessageBundle(Language lang) {\n    return ResourceBundleTools.getMessageBundle(lang);\n  }\n\n  private List<Rule> getAllBuiltinRules(Language language, ResourceBundle messages, UserConfig userConfig, GlobalConfig globalConfig) {\n    try {\n      List<Rule> rules = new ArrayList<>(language.getRelevantRules(messages, userConfig, motherTongue, altLanguages));\n      rules.addAll(language.getRelevantRulesGlobalConfig(messages, globalConfig, userConfig, motherTongue, altLanguages));\n      return rules;\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not get rules of language \" + language, e);\n    }\n  }\n\n  /**\n   * Set a PrintStream that will receive verbose output. Set to\n   * {@code null} (which is the default) to disable verbose output.\n   */\n  public void setOutput(PrintStream printStream) {\n    this.printStream = printStream;\n    GlobalConfig.setVerbose(printStream != null);\n  }\n\n  /**\n   * Load pattern rules from an XML file. Use {@link #addRule(Rule)} to add these\n   * rules to the checking process.\n   *\n   * @param filename path to an XML file in the classpath or in the filesystem - the classpath is checked first\n   * @return a List of {@link PatternRule} objects","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/JLanguageTool.java#L509-L545","documentation":"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.","triggerScenarios":"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.","commonSituations":"Incomplete jar/classpath (language resources stripped by shading or packaging); read-permission problems on resource files; custom Language whose rule-loading code throws IOException.","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."],"exampleFix":"// before (custom language resource read from working dir)\nInputStream s = new FileInputStream(\"rules.xml\");\n// after (package resource in jar and read via classloader)\nInputStream s = getClass().getResourceAsStream(\"/org/languagetool/rules/rules.xml\");","handlingStrategy":"try-catch","validationCode":"// ensure the language module jar contains its rule resources\nURL res = getClass().getResource(\"/org/languagetool/rules/<lang>/grammar.xml\");\nif (res == null) throw new IllegalStateException(\"language rule resources missing from classpath\");","typeGuard":null,"tryCatchPattern":"try {\n  lt = new JLanguageTool(language);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException io) {\n    logger.error(\"Missing/unreadable rule resource for \" + language + \": \" + io.getMessage());\n  }\n  throw e;\n}","preventionTips":["Check resource presence via classpath lookups before constructing instances.","Avoid shading configs that strip language module resources.","Verify file read permissions in deployment images."],"tags":["rules","resource-loading","io","runtime-exception"],"backgroundTag":"resource-not-found","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"}