SonarSource/sonarqube · error · IllegalStateException

Could not read properties from file:

Error message

Could not read properties from file: 

What it means

After validating the argument count, loadPropsFromCommandLineArgs opens the property file as UTF-8 and loads it. Any exception during reading/parsing (FileNotFoundException, IOException, malformed properties) is wrapped in this IllegalStateException carrying the file path, with the original exception as cause.

Source

Thrown at server/sonar-process/src/main/java/org/sonar/process/ConfigurationUtils.java:51

  private ConfigurationUtils() {
    // Utility class
  }

  static Props loadPropsFromCommandLineArgs(String[] args) {
    if (args.length != 1) {
      throw new IllegalArgumentException("Only a single command-line argument is accepted " +
        "(absolute path to configuration file)");
    }

    File propertyFile = new File(args[0]);
    Properties properties = new Properties();
    Reader reader = null;
    try {
      reader = new InputStreamReader(new FileInputStream(propertyFile), StandardCharsets.UTF_8);
      properties.load(reader);
    } catch (Exception e) {
      throw new IllegalStateException("Could not read properties from file: " + args[0], e);
    } finally {
      IOUtils.closeQuietly(reader);
      deleteQuietly(propertyFile);
    }
    return new Props(properties);
  }
}

View on GitHub (pinned to 184c821202)

Solutions

  1. Look at the caused-by exception to distinguish missing file vs IO error vs parse error
  2. Restart SonarQube via its standard scripts so it regenerates the temporary configuration file
  3. Pass the correct absolute path to an existing, readable properties file
  4. Ensure only one process instance runs against the same temp conf location (no concurrent deletion)

Example fix

// before
java org.sonar.process.Search /wrong/path/conf.properties
// after
java org.sonar.process.Search /opt/sonarqube/temp/conf/search.properties
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(args[0]);
if (!f.isFile() || !f.canRead()) throw new IllegalStateException("Conf file missing/unreadable: " + args[0]);

Try / catch

try { Props p = ConfigurationUtils.loadPropsFromCommandLineArgs(args); } catch (IllegalStateException e) { log.error("{} cause={}", e.getMessage(), e.getCause()); throw e; }

Prevention

When it happens

Trigger: args[0] points to a file that does not exist or is unreadable; the file is deleted before reading (it is deleted afterwards by design, so a retry will always fail); IO error mid-read; malformed .properties content.

Common situations: Temp configuration directory wiped between process start and config load; running the process manually with a wrong path; two processes racing and one deleting the temp conf file; encoding corruption.

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/7aa679a0e05eab72. Report an issue: GitHub.