{"record":{"id":"810a7e76e2af945c","repo":"SonarSource/sonarqube","slug":"s-folder-not-found","errorCode":null,"errorMessage":"%s folder not found","messagePattern":"(.+?) folder not found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":500,"severity":"critical","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/BatchIndex.java","lineNumber":72,"sourceCode":"\n  @Override\n  public void start() {\n    StringBuilder sb = new StringBuilder();\n    batchDir = new File(fs.getHomeDir(), \"lib/scanner\");\n    if (batchDir.exists()) {\n      Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE, FileFilterUtils.directoryFileFilter());\n      for (File file : files) {\n        String filename = file.getName();\n        if (StringUtils.endsWith(filename, \".jar\")) {\n          try (FileInputStream fis = new FileInputStream(file)) {\n            sb.append(filename).append('|').append(DigestUtils.md5Hex(fis)).append(CharUtils.LF);\n          } catch (IOException e) {\n            throw new IllegalStateException(\"Fail to compute hash\", e);\n          }\n        }\n      }\n    } else {\n      throw new IllegalStateException(format(\"%s folder not found\", batchDir.getAbsolutePath()));\n    }\n    this.index = sb.toString();\n  }\n\n  @Override\n  public void stop() {\n    // Nothing to do\n  }\n\n  String getIndex() {\n    return index;\n  }\n\n  File getFile(String filename) {\n    try {\n      File input = new File(batchDir, filename);\n      if (!FilenameUtils.directoryContains(batchDir.getCanonicalPath(), input.getCanonicalPath()) || !input.exists()) {\n        throw new NotFoundException(\"Bad filename: \" + filename);","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/BatchIndex.java#L54-L90","documentation":"BatchIndex.start() requires the batch directory (holding the JARs served to scanners) to exist; if it does not, it throws this IllegalStateException with the absolute path. This prevents the batch web services from serving scanner files from a nonexistent location.","triggerScenarios":"Starting the Compute/Web server or invoking batch endpoints when the configured batch directory (e.g. sonar.path.home/lib/batch or an overridden path) is absent — typically a broken or incomplete installation or a bad path override.","commonSituations":"Manual install where lib/batch was never copied; deleted batch dir during cleanup; overridden sonar.path properties pointing at a wrong location; container images built without the batch libs.","solutions":["Verify the batch directory exists at the path in the message; restore it from a full distribution","If sonar.path.* properties override it, correct the configured path and restart","Reinstall/repair the SonarQube server — the batch folder ships with the distribution","If running in a container, use the official image or fix the Dockerfile to include lib/batch"],"exampleFix":"// before (missing dir)\n/opt/sonarqube/lib/  (no batch/ folder)\n// after\ncp -r sonarqube-9.9/lib/batch /opt/sonarqube/lib/","handlingStrategy":"validation","validationCode":"// Verify the batch directory exists before starting the server:\nFile batchDir = new File(sonarHome, \"lib/batch\");\nif (!batchDir.isDirectory()) {\n  throw new IllegalStateException(\"Batch folder missing at \" + batchDir + \" — reinstall from a full distribution\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  batchIndex.start();\n} catch (IllegalStateException e) {\n  if (e.getMessage() != null && e.getMessage().endsWith(\"folder not found\")) {\n    log.error(\"Batch directory missing — restore lib/batch from the official distribution\", e);\n  } else { throw e; }\n}","preventionTips":["Install SonarQube from a complete official distribution; never prune lib/","If overriding sonar.path.* properties, confirm the target path exists before startup","In container builds, ensure lib/batch is copied, not volume-mounted empty","Re-check the install after any manual cleanup scripts run"],"tags":["batch","directory-not-found","installation","startup"],"backgroundTag":"directory-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"}