{"record":{"id":"60f272a2e9359dbd","repo":"SonarSource/sonarqube","slug":"cannot-open-file-propsfile","errorCode":null,"errorMessage":"\"Cannot open file \" + propsFile","messagePattern":"\"Cannot open file \" \\+ propsFile","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sonar-shutdowner/src/main/java/org/sonar/application/Shutdowner.java","lineNumber":77,"sourceCode":"      return appJar.getParentFile().getParentFile();\n    } catch (URISyntaxException e) {\n      throw new IllegalStateException(\"Cannot detect path of shutdowner jar file\", e);\n    }\n  }\n\n  /**\n   * Loads the configuration file ${homeDir}/conf/sonar.properties.\n   * An empty {@link Properties} is returned if the file does not exist.\n   */\n  static Properties loadPropertiesFile(File homeDir) {\n    Properties p = new Properties();\n    File propsFile = new File(new File(homeDir, \"conf\"), \"sonar.properties\");\n    if (propsFile.exists()) {\n      try (Reader reader = new InputStreamReader(new FileInputStream(propsFile), UTF_8)) {\n        p.load(reader);\n        return p;\n      } catch (IOException e) {\n        throw new IllegalStateException(\"Cannot open file \" + propsFile, e);\n      }\n    } else {\n      throw new IllegalStateException(\"Configuration file not found: \" + propsFile);\n    }\n  }\n\n  static File resolveTempDir(Properties p) {\n    return new File(Optional.ofNullable(p.getProperty(\"sonar.path.temp\")).orElse(\"temp\"));\n  }\n\n  static void askForHardStop(File tmpDir) throws IOException {\n    writeToShareMemory(tmpDir, 1, (byte) 0xFF);\n  }\n\n  private static void writeToShareMemory(File tmpDir, int offset, byte value) throws IOException {\n    try (RandomAccessFile sharedMemory = new RandomAccessFile(new File(tmpDir, \"sharedmemory\"), \"rw\")) {\n      // Using values from org.sonar.process.ProcessCommands\n      MappedByteBuffer mappedByteBuffer = sharedMemory.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, 50L * 10);","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-shutdowner/src/main/java/org/sonar/application/Shutdowner.java#L59-L95","documentation":"Shutdowner.loadPropertiesFile reads ${homeDir}/conf/sonar.properties as UTF-8 into a Properties object. If the file exists but reading fails (IOException), it throws IllegalStateException \"Cannot open file <path>\". Note loadPropertiesFile only reaches the read when propsFile.exists() is true; the error indicates an I/O problem, not a missing file.","triggerScenarios":"Calling p() -> loadPropertiesFile() when conf/sonar.properties exists but cannot be read: permission denied, file locked by another process, or an IO error during load.","commonSituations":"conf/sonar.properties owned by another user with restrictive permissions; running the shutdowner as a service account lacking read access; the file being a directory or locked on Windows.","solutions":["Fix file permissions so the shutdowner's user can read ${SONARQUBE_HOME}/conf/sonar.properties (e.g. chmod 640, correct owner).","Close/stop the other process holding a lock on the file (Windows).","Verify the path is a regular file, not a directory or symlink to an unreadable target.","Check the wrapped IOException cause for the precise OS-level error."],"exampleFix":"// before\n$ ls -l conf/sonar.properties\n-rw------- 1 root root conf/sonar.properties\n\n// after: grant read access to the sonarqube user\n$ sudo chown sonarqube:sonarqube conf/sonar.properties\n$ sudo chmod 640 conf/sonar.properties","handlingStrategy":"try-catch","validationCode":"// Java\nFile propsFile = new File(new File(homeDir, \"conf\"), \"sonar.properties\");\nif (!propsFile.isFile() || !propsFile.canRead()) {\n  throw new IllegalStateException(\"Cannot read config file: \" + propsFile);\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  Properties p = shutdowner.p();\n} catch (IllegalStateException e) {\n  // inspect cause (IOException): fix permissions or file lock, then retry\n}","preventionTips":["Run SonarQube services under a user that owns conf/sonar.properties.","Set restrictive-but-readable permissions (e.g. 640, owner sonarqube).","Keep conf/ as a plain directory of regular files; avoid exotic symlinks.","On Windows, ensure no other process holds the file open during startup."],"tags":["sonarqube","configuration","file-io","permissions"],"backgroundTag":"file-read-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}