{"record":{"id":"c661f7690d2c7ac0","repo":"SonarSource/sonarqube","slug":"fail-to-load-file","errorCode":null,"errorMessage":"Fail to load file ","messagePattern":"Fail to load file ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/sonar-webserver/src/main/java/org/sonar/server/platform/web/WebPagesCache.java","lineNumber":102,"sourceCode":"    this.status = status;\n    HTML_PATHS.forEach(path -> indexHtmlByPath.put(path, provide(path)));\n  }\n\n  private String provide(String path) {\n    getClass().getResourceAsStream(INDEX_HTML_PATH);\n    return loadHtmlFile(path, status.name());\n  }\n\n  private String loadHtmlFile(String path, String serverStatus) {\n    try (InputStream input = servletContext.getResourceAsStream(path)) {\n      String template = IOUtils.toString(requireNonNull(input), UTF_8);\n      return template\n        .replace(WEB_CONTEXT_PLACEHOLDER, servletContext.getContextPath())\n        .replace(SERVER_STATUS_PLACEHOLDER, serverStatus)\n        .replace(INSTANCE_PLACEHOLDER, WebPagesCache.SONARQUBE_INSTANCE_VALUE)\n        .replace(OFFICIAL_PLACEHOLDER, String.valueOf(officialDistribution.check()));\n    } catch (Exception e) {\n      throw new IllegalStateException(\"Fail to load file \" + path, e);\n    }\n  }\n}\n","sourceCodeStart":84,"sourceCodeEnd":106,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/WebPagesCache.java#L84-L106","documentation":"WebPagesCache loads an HTML page template from disk, substitutes placeholders (context path, server status, etc.), and wraps any failure in an IllegalStateException naming the file path. It is thrown during web server startup when a bundled UI template cannot be read or processed.","triggerScenarios":"Calling loadHtmlFile with a path that does not exist or is unreadable on disk, or the template replacement steps throw (e.g. officialDistribution.check() fails). Called from provide() while wiring the web server.","commonSituations":"Corrupted or partial SonarQube installation where webapp files are missing; wrong SONARQUBE_HOME/web dir; file permissions; a failing distribution check throwing inside the try block.","solutions":["Verify the webapp template file exists at the reported path under the SonarQube installation","Check file read permissions for the user running SonarQube","Reinstall/repair the SonarQube distribution to restore corrupted webapp files","Inspect the wrapped cause in the stack trace for the real failure (e.g. officialDistribution.check())"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"java.nio.file.Path p = java.nio.file.Paths.get(path);\nif (!java.nio.file.Files.isRegularFile(p) || !java.nio.file.Files.isReadable(p)) {\n  throw new IllegalStateException(\"Template not readable: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try {\n  PageBean page = pagesCache.provide(...);\n} catch (IllegalStateException e) {\n  LOG.error(\"Page template unavailable\", e);\n  return Response.status(503).build();\n}","preventionTips":["Verify webapp files after installation or upgrades","Run SonarQube with a user that has read access to all installation files","Monitor disk health and installation integrity"],"tags":["startup","file-not-found","webserver"],"backgroundTag":"file-not-found","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}