SonarSource/sonarqube · critical · IllegalStateException
folder not found
Error message
%s folder not found
What it means
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.
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
Example fix
// before (missing dir) /opt/sonarqube/lib/ (no batch/ folder) // after cp -r sonarqube-9.9/lib/batch /opt/sonarqube/lib/
Defensive patterns
Strategy: validation
Validate before calling
// Verify the batch directory exists before starting the server:
File batchDir = new File(sonarHome, "lib/batch");
if (!batchDir.isDirectory()) {
throw new IllegalStateException("Batch folder missing at " + batchDir + " — reinstall from a full distribution");
} Try / catch
try {
batchIndex.start();
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().endsWith("folder not found")) {
log.error("Batch directory missing — restore lib/batch from the official distribution", e);
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Already started
- Bad filename
- Cannot detect path of main jar file
- ############################################################…
- Fail to compute hash
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/810a7e76e2af945c.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/BatchIndex.java:72
@Override
public void start() {
StringBuilder sb = new StringBuilder();
batchDir = new File(fs.getHomeDir(), "lib/scanner");
if (batchDir.exists()) {
Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE, FileFilterUtils.directoryFileFilter());
for (File file : files) {
String filename = file.getName();
if (StringUtils.endsWith(filename, ".jar")) {
try (FileInputStream fis = new FileInputStream(file)) {
sb.append(filename).append('|').append(DigestUtils.md5Hex(fis)).append(CharUtils.LF);
} catch (IOException e) {
throw new IllegalStateException("Fail to compute hash", e);
}
}
}
} else {
throw new IllegalStateException(format("%s folder not found", batchDir.getAbsolutePath()));
}
this.index = sb.toString();
}
@Override
public void stop() {
// Nothing to do
}
String getIndex() {
return index;
}
File getFile(String filename) {
try {
File input = new File(batchDir, filename);
if (!FilenameUtils.directoryContains(batchDir.getCanonicalPath(), input.getCanonicalPath()) || !input.exists()) {
throw new NotFoundException("Bad filename: " + filename);View on GitHub (pinned to 184c821202)