SonarSource/sonarqube · error · NotFoundException
Unable to find JRE
Error message
Unable to find JRE '%s'
What it means
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.
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
Example fix
// before
return new FileInputStream("jres/" + jreFilename);
// after
File jre = new File(fs.getHomeDir(), "jres/" + jreFilename);
if (!jre.isFile()) {
throw new NotFoundException(String.format("Unable to find JRE '%s'", jreFilename));
}
return new FileInputStream(jre); Defensive patterns
Strategy: validation
Validate before calling
const jres = await fetch(`${baseUrl}/api/v2/analysis/jres`).then(r => r.json());
if (!jres.jres.some(j => j.filename === requestedJre)) {
throw new Error(`JRE '${requestedJre}' not offered by this server; pick one from the jres list`);
} Type guard
function hasJre(jreList, filename) {
return jreList?.jres?.some(j => typeof j.filename === 'string' && j.filename === filename) ?? false;
} Try / catch
try {
const jre = await fetchJreBinary(filename);
} catch (err) {
if (err.status === 404) {
// fall back to the first JRE listed by the server
} else { throw err; }
} Prevention
- 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
When it happens
Trigger: GET api/v2/analysis/jres/{jreFilename} (via JresHandlerImpl.getJreBinary) where jreFilename does not correspond to a file in jres/ relative to the working directory.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Can get file
- "The property " + ENCRYPTION_SECRET_KEY_PATH + " does not…
- Unable to find file
- A plugin is storing excessively large data in the following…
- A version event already exists on analysis
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/7db7f859f07e39c6.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/service/JresHandlerImpl.java:104
Predicate<JreInfoRestResponse> archFilter = isBlank(arch) ? jre -> true : (jre -> Arch.from(jre.arch()) == Arch.from(arch));
return metadata.values().stream()
.filter(osFilter)
.filter(archFilter)
.toList();
}
@Override
public JreInfoRestResponse getJreMetadata(String id) {
return Optional.ofNullable(metadata.get(id))
.orElseThrow(() -> new NotFoundException("JRE not found for id: " + id));
}
@Override
public InputStream getJreBinary(String jreFilename) {
try {
return new FileInputStream("jres/" + jreFilename);
} catch (FileNotFoundException fileNotFoundException) {
throw new NotFoundException(String.format("Unable to find JRE '%s'", jreFilename));
}
}
}
View on GitHub (pinned to 184c821202)