SonarSource/sonarqube · error · SonarException

Fail to load file:

Error message

Fail to load file: 

What it means

SonarException raised in DefaultI18n.readInputStream when IOUtils.toString fails to read a localized L10n bundle file (the path derived from bundle base, language and filename) from the classloader. It means the resource was found but could not be read/decoded from the stream, typically an I/O problem in the plugin JAR; the failing path is included after the message prefix.

Solutions

  1. Check the reported bundle file exists and is readable
  2. Reinstall/repair the language pack plugin
  3. Inspect the wrapped IOException cause
  4. Verify UTF-8 encoding compatibility of the resource
Defensive patterns

Strategy: try-catch

Try / catch

try {
  String bundle = messageFromFile(path, input);
} catch (SonarException e) {
  LOG.warn("Failed to load i18n bundle {}", filePath, e);
  return defaultBundle;
}

Prevention

When it happens

Trigger: Calling messageFromFile for a bundle file that exists but cannot be read (I/O error mid-read, stream closed, disk failure, or resource stream returning an erroring stream).

Common situations: Corrupted language-pack plugin jars; partially deployed l10n bundles; unreadable files on disk.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/825d3ecf3eb88a66. Report an issue: GitHub.

Appendix: source

Thrown at sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java:217

    String filePath = bundleBase.replace('.', '/');
    if (!"en".equals(locale.getLanguage())) {
      filePath += "_" + locale.getLanguage();
    }
    filePath += "/" + filename;
    InputStream input = classloader.getResourceAsStream(filePath);
    if (input != null) {
      result = readInputStream(filePath, input);
    }
    return result;
  }

  private static String readInputStream(String filePath, InputStream input) {
    String result;
    try {
      result = IOUtils.toString(input, UTF_8);
    } catch (IOException e) {
      throw new SonarException("Fail to load file: " + filePath, e);
    } finally {
      IOUtils.closeQuietly(input);
    }
    return result;
  }

  public Set<String> getPropertyKeys() {
    return propertyToBundles.keySet();
  }

  public Locale getEffectiveLocale(Locale locale) {
    Locale bundleLocale = ResourceBundle.getBundle(BUNDLE_PACKAGE + "core", locale, this.classloader, this.control).getLocale();
    locale.getISO3Language();
    return bundleLocale.getLanguage().isEmpty() ? Locale.ENGLISH : bundleLocale;
  }

  @CheckForNull
  private static String formatMessage(@Nullable String message, Object... parameters) {

View on GitHub (pinned to 184c821202)