SonarSource/sonarqube · error · NotFoundException
Unable to find file
Error message
Unable to find file: %s
What it means
Thrown by the v2 Scanner Engine download endpoint when the scanner engine JAR file, as reported by ScannerEngineHandler, cannot be opened for reading because the file no longer exists or is unreadable. SonarQube wraps the FileNotFoundException in a 404 NotFoundException naming the file.
Solutions
- Ensure the SonarQube installation directory contains lib/scanner with the scanner engine JAR on the web server node
- Check file permissions so the SonarQube process user can read the JAR
- Reinstall/repair the SonarQube distribution to restore the scanner engine artifacts
- If running in containers, verify the installation volume is mounted on the node serving the request
Example fix
// before
return new InputStreamResource(new FileInputStream(scannerEngine));
// after
if (!scannerEngine.exists() || !scannerEngine.canRead()) {
throw new ServerException("Scanner engine file missing or unreadable: " + scannerEngine.getAbsolutePath());
}
return new InputStreamResource(new FileInputStream(scannerEngine)); Defensive patterns
Strategy: try-catch
Validate before calling
// Node-side guard: ensure the scanner engine is deployed
File scannerDir = new File(sonarHome, "lib/scanner");
if (!scannerDir.isDirectory() || Objects.requireNonNull(scannerDir.list(f -> f.getName().endsWith(".jar"))).length == 0) {
throw new IllegalStateException("Scanner engine JAR missing; reinstall the SonarQube distribution");
} Type guard
function isScannerEngineAvailable(client) {
return fetch(`${client.baseUrl}/api/v2/analysis/engine`, { method: 'HEAD' }).then(r => r.ok);
} Try / catch
try {
const stream = await downloadScannerEngine();
} catch (err) {
if (err.status === 404) {
// reinstall/repair server distribution or alert ops that lib/scanner is missing
} else { throw err; }
} Prevention
- Do not delete or prune files under <sonarHome>/lib/scanner
- Use official distribution images/zips rather than partial file copies
- Verify the installation after upgrades (existence of lib/scanner JARs)
- Keep consistent node installations when running a cluster
When it happens
Trigger: GET api/v2/analysis/engine (downloadScannerEngine) when the file returned by scannerEngineHandler.getScannerEngine() was deleted between existence check/lookup and the FileInputStream open, or resides on a volume not mounted in the process.
Common situations: Missing or partially deployed scan directory after an upgrade; the compute/web node's home dir lacking lib/scanner contents; permissions making the file unreadable; multiple nodes with inconsistent installations.
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
- Scanner directory not found
- "The property " + ENCRYPTION_SECRET_KEY_PATH + " does not…
- Unable to find JRE
- A plugin is storing excessively large data in the following…
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/76113207f6d57083.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/controller/DefaultScannerEngineController.java:53
private final ScannerEngineHandler scannerEngineHandler;
public DefaultScannerEngineController(ScannerEngineHandler scannerEngineHandler) {
this.scannerEngineHandler = scannerEngineHandler;
}
@Override
public EngineInfoRestResponse getScannerEngineMetadata() {
ScannerEngineMetadata metadata = scannerEngineHandler.getScannerEngineMetadata();
return new EngineInfoRestResponse(metadata.filename(), metadata.checksum());
}
@Override
public InputStreamResource downloadScannerEngine() {
File scannerEngine = scannerEngineHandler.getScannerEngine();
try {
return new InputStreamResource(new FileInputStream(scannerEngine));
} catch (FileNotFoundException e) {
throw new NotFoundException(format("Unable to find file: %s", scannerEngine.getName()));
}
}
}
View on GitHub (pinned to 184c821202)