{"record":{"id":"76113207f6d57083","repo":"SonarSource/sonarqube","slug":"unable-to-find-file-s","errorCode":null,"errorMessage":"Unable to find file: %s","messagePattern":"Unable to find file: (.+?)","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/controller/DefaultScannerEngineController.java","lineNumber":53,"sourceCode":"  private final ScannerEngineHandler scannerEngineHandler;\n\n  public DefaultScannerEngineController(ScannerEngineHandler scannerEngineHandler) {\n    this.scannerEngineHandler = scannerEngineHandler;\n  }\n\n  @Override\n  public EngineInfoRestResponse getScannerEngineMetadata() {\n    ScannerEngineMetadata metadata = scannerEngineHandler.getScannerEngineMetadata();\n    return new EngineInfoRestResponse(metadata.filename(), metadata.checksum());\n  }\n\n  @Override\n  public InputStreamResource downloadScannerEngine() {\n    File scannerEngine = scannerEngineHandler.getScannerEngine();\n    try {\n      return new InputStreamResource(new FileInputStream(scannerEngine));\n    } catch (FileNotFoundException e) {\n      throw new NotFoundException(format(\"Unable to find file: %s\", scannerEngine.getName()));\n    }\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/analysis/controller/DefaultScannerEngineController.java#L35-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nreturn new InputStreamResource(new FileInputStream(scannerEngine));\n// after\nif (!scannerEngine.exists() || !scannerEngine.canRead()) {\n  throw new ServerException(\"Scanner engine file missing or unreadable: \" + scannerEngine.getAbsolutePath());\n}\nreturn new InputStreamResource(new FileInputStream(scannerEngine));","handlingStrategy":"try-catch","validationCode":"// Node-side guard: ensure the scanner engine is deployed\nFile scannerDir = new File(sonarHome, \"lib/scanner\");\nif (!scannerDir.isDirectory() || Objects.requireNonNull(scannerDir.list(f -> f.getName().endsWith(\".jar\"))).length == 0) {\n  throw new IllegalStateException(\"Scanner engine JAR missing; reinstall the SonarQube distribution\");\n}","typeGuard":"function isScannerEngineAvailable(client) {\n  return fetch(`${client.baseUrl}/api/v2/analysis/engine`, { method: 'HEAD' }).then(r => r.ok);\n}","tryCatchPattern":"try {\n  const stream = await downloadScannerEngine();\n} catch (err) {\n  if (err.status === 404) {\n    // reinstall/repair server distribution or alert ops that lib/scanner is missing\n  } else { throw err; }\n}","preventionTips":["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"],"tags":["sonarqube","file-not-found","scanner-engine"],"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"}