{"record":{"id":"7db7f859f07e39c6","repo":"SonarSource/sonarqube","slug":"unable-to-find-jre-s","errorCode":null,"errorMessage":"Unable to find JRE '%s'","messagePattern":"Unable to find JRE '(.+?)'","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/service/JresHandlerImpl.java","lineNumber":104,"sourceCode":"    Predicate<JreInfoRestResponse> archFilter = isBlank(arch) ? jre -> true : (jre -> Arch.from(jre.arch()) == Arch.from(arch));\n    return metadata.values().stream()\n      .filter(osFilter)\n      .filter(archFilter)\n      .toList();\n  }\n\n  @Override\n  public JreInfoRestResponse getJreMetadata(String id) {\n    return Optional.ofNullable(metadata.get(id))\n      .orElseThrow(() -> new NotFoundException(\"JRE not found for id: \" + id));\n  }\n\n  @Override\n  public InputStream getJreBinary(String jreFilename) {\n    try {\n      return new FileInputStream(\"jres/\" + jreFilename);\n    } catch (FileNotFoundException fileNotFoundException) {\n      throw new NotFoundException(String.format(\"Unable to find JRE '%s'\", jreFilename));\n    }\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":108,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/service/JresHandlerImpl.java#L86-L108","documentation":"Thrown when the requested JRE binary cannot be found on disk under the 'jres/' directory while serving GET of a JRE for a scanner. SonarQube converts the FileNotFoundException into a 404 NotFoundException naming the JRE file.","triggerScenarios":"GET api/v2/analysis/jres/{jreFilename} (via JresHandlerImpl.getJreBinary) where jreFilename does not correspond to a file in jres/ relative to the working directory.","commonSituations":"Scanner requesting a JRE filename the server build does not ship (version mismatch), JRE files removed by cleanup, running server from a non-standard working directory so the relative 'jres/' path resolves incorrectly.","solutions":["Use a jreFilename exactly as listed by the jres listing endpoint","Verify the server distribution's jres/ directory contains the requested JRE file","Restart/repair the SonarQube installation to restore shipped JREs","Ensure the server process runs from the installation home so the relative 'jres/' path resolves correctly"],"exampleFix":"// before\nreturn new FileInputStream(\"jres/\" + jreFilename);\n// after\nFile jre = new File(fs.getHomeDir(), \"jres/\" + jreFilename);\nif (!jre.isFile()) {\n  throw new NotFoundException(String.format(\"Unable to find JRE '%s'\", jreFilename));\n}\nreturn new FileInputStream(jre);","handlingStrategy":"validation","validationCode":"const jres = await fetch(`${baseUrl}/api/v2/analysis/jres`).then(r => r.json());\nif (!jres.jres.some(j => j.filename === requestedJre)) {\n  throw new Error(`JRE '${requestedJre}' not offered by this server; pick one from the jres list`);\n}","typeGuard":"function hasJre(jreList, filename) {\n  return jreList?.jres?.some(j => typeof j.filename === 'string' && j.filename === filename) ?? false;\n}","tryCatchPattern":"try {\n  const jre = await fetchJreBinary(filename);\n} catch (err) {\n  if (err.status === 404) {\n    // fall back to the first JRE listed by the server\n  } else { throw err; }\n}","preventionTips":["Discover available JRE filenames from the listing endpoint instead of hardcoding","After server upgrades, refresh the JRE filename used by scanners","Ensure the server runs from its installation home so relative 'jres/' paths resolve","Don't manually delete files under the server distribution"],"tags":["sonarqube","file-not-found","jre"],"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"}