SonarSource/sonarqube · error · MessageException
Directory does not exist:
Error message
Directory does not exist:
What it means
JdbcSettings.driverPath resolves the directory holding the JDBC driver JAR, relative to the SonarQube home directory. If the configured path (provider.path) does not exist on disk, a MessageException 'Directory does not exist: <path>' is thrown at startup. It guards against misconfigured sonar.jdbc.driverPath-style settings.
Source
Thrown at server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java:84
props.set(JDBC_DRIVER_PATH.getKey(), driverPath);
if (provider == Provider.SQLSERVER) {
List<String> additionalPaths = additionalMsSqlLibPaths(homeDir);
String libPathsToBeAddedToClasspath = String.join(";", additionalPaths);
props.set(JDBC_ADDITIONAL_LIB_PATHS.getKey(), libPathsToBeAddedToClasspath);
}
}
private static List<String> additionalMsSqlLibPaths(File homeDir) {
File dir = new File(homeDir, Provider.SQLSERVER.path);
List<File> files = new ArrayList<>(FileUtils.listFiles(dir, new String[] {"jar"}, false));
return files.stream().filter(f -> !f.getName().startsWith("mssql-jdbc")).map(File::getAbsolutePath).toList();
}
String driverPath(File homeDir, Provider provider) {
String dirPath = provider.path;
File dir = new File(homeDir, dirPath);
if (!dir.exists()) {
throw new MessageException("Directory does not exist: " + dirPath);
}
List<File> files = new ArrayList<>(FileUtils.listFiles(dir, new String[] {"jar"}, false));
if (files.isEmpty()) {
throw new MessageException("Directory does not contain JDBC driver: " + dirPath);
}
if (files.size() > 1 && Provider.SQLSERVER != provider) {
throw new MessageException("Directory must contain only one JAR file: " + dirPath);
} else if (Provider.SQLSERVER == provider) {
return files.stream().filter(f -> f.getName().startsWith("mssql-jdbc")).findFirst()
.orElseThrow(() -> new MessageException("Directory does not contain JDBC driver: " + dirPath)).getAbsolutePath();
}
return files.get(0).getAbsolutePath();
}
Provider resolveProviderAndEnforceNonnullJdbcUrl(Props props) {
String url = props.value(JDBC_URL.getKey());
Integer embeddedDatabasePort = props.valueAsInt(JDBC_EMBEDDED_PORT.getKey());
View on GitHub (pinned to 184c821202)
Solutions
- Create the configured directory under SONARQUBE_HOME or correct the path in the configuration
- Verify the directory exists relative to the SonarQube home directory, not the current directory
- For SQL Server, ensure extensions/jdbc-driver/mssql exists if using the bundled provider
- Check file permissions so the process user can see the directory
Example fix
// before (config points at missing dir) jdbcProviderPath = "extensions/jdbc-driver/postgres" // after mkdir -p $SONARQUBE_HOME/extensions/jdbc-driver/postgres # or fix the configured path
Defensive patterns
Strategy: validation
Validate before calling
File dir = new File(homeDir, providerPath);
if (!dir.isDirectory()) throw new IllegalStateException("Driver directory missing: " + dir.getAbsolutePath()); Type guard
static boolean validDriverDir(File homeDir, String path) { File d = new File(homeDir, path); return d.exists() && d.isDirectory(); } Try / catch
try { settings.start(); } catch (MessageException e) { if (e.getMessage().startsWith("Directory does not exist")) { /* fix config or create dir */ } throw e; } Prevention
- Keep driver directories relative to SONARQUBE_HOME, not the working directory
- Verify paths after moving/reinstalling the server
- Script the driver directory creation as part of provisioning
- Check read/execute permissions for the service user
When it happens
Trigger: Starting the server with a JDBC provider whose configured driver directory (e.g. conf/third-party-driver or extensions/jdbc-driver/<db>) does not exist under the home directory.
Common situations: Typo in the configured driver path; moving or renaming the SonarQube installation directory; running from a different working directory than expected; packaging a custom driver in the wrong folder.
Related errors
- Can not connect to database. Please check connectivity and s
- Directory does not contain JDBC driver:
- Directory must contain only one JAR file:
- Github configuration is not complete. Please check your conf
- Configuration is not complete : %s
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/68ee8a6c015397c8.
Report an issue: GitHub.