languagetool-org/languagetool · error · RuntimeException

Could not load data from

Error message

Could not load data from ${path}

What it means

Generic I/O guard in StringTools.loadLines: reading the resource at the given path as UTF-8 lines failed. The input at fault is the classpath/resource path; the method is deprecated in favor of DataBroker#getFromResourceDirAsLines.

Solutions

  1. Confirm the resource exists at the given path in the resource dir
  2. Check the file is readable and not corrupted
  3. Migrate to DataBroker#getFromResourceDirAsLines, which is the supported loader
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tools/StringTools.java:747 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/b73e7d6b40a31ac4. Report an issue: GitHub.

Appendix: source

Thrown at languagetool-core/src/main/java/org/languagetool/tools/StringTools.java:747

   * @since 4.6
   * @deprecated use DataBroker#getFromResourceDirAsLines(java.lang.String) instead (NOTE: it won't handle comments)
   */
  public static List<String> loadLines(String path) {
    InputStream stream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(path);
    List<String> l = new ArrayList<>();
    try (
      InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
      BufferedReader br = new BufferedReader(reader)
    ) {
      String line;
      while ((line = br.readLine()) != null) {
        if (line.isEmpty() || line.charAt(0) == '#') {   // ignore comments
          continue;
        }
        l.add(line);
      }
    } catch (IOException e) {
      throw new RuntimeException("Could not load data from " + path, e);
    }
    return Collections.unmodifiableList(l);
  }

  /**
   * Will turn a string into a typical rule ID, i.e. uppercase and
   * "_" instead of spaces.
   *
   * All non-ASCII characters are replaced with "_", EXCEPT for
   * Latin-1 ranges U+00C0-U+00D6 and U+00D8-U+00DE.
   *
   * "de" locales have a special implementation (ä =&gt; ae, etc.).
   *
   * @param language LT language object, used to apply language-specific normalisation rules.
   *
   * @since 5.1
   */
  public static String toId(String input, Language language) {

View on GitHub (pinned to 2e990059ce)