{"record":{"id":"68ee8a6c015397c8","repo":"SonarSource/sonarqube","slug":"directory-does-not-exist","errorCode":null,"errorMessage":"Directory does not exist: ","messagePattern":"Directory does not exist: ","errorType":"validation","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java","lineNumber":84,"sourceCode":"    props.set(JDBC_DRIVER_PATH.getKey(), driverPath);\n    if (provider == Provider.SQLSERVER) {\n      List<String> additionalPaths = additionalMsSqlLibPaths(homeDir);\n      String libPathsToBeAddedToClasspath = String.join(\";\", additionalPaths);\n      props.set(JDBC_ADDITIONAL_LIB_PATHS.getKey(), libPathsToBeAddedToClasspath);\n    }\n  }\n\n  private static List<String> additionalMsSqlLibPaths(File homeDir) {\n    File dir = new File(homeDir, Provider.SQLSERVER.path);\n    List<File> files = new ArrayList<>(FileUtils.listFiles(dir, new String[] {\"jar\"}, false));\n    return files.stream().filter(f -> !f.getName().startsWith(\"mssql-jdbc\")).map(File::getAbsolutePath).toList();\n  }\n\n  String driverPath(File homeDir, Provider provider) {\n    String dirPath = provider.path;\n    File dir = new File(homeDir, dirPath);\n    if (!dir.exists()) {\n      throw new MessageException(\"Directory does not exist: \" + dirPath);\n    }\n    List<File> files = new ArrayList<>(FileUtils.listFiles(dir, new String[] {\"jar\"}, false));\n    if (files.isEmpty()) {\n      throw new MessageException(\"Directory does not contain JDBC driver: \" + dirPath);\n    }\n    if (files.size() > 1 && Provider.SQLSERVER != provider) {\n      throw new MessageException(\"Directory must contain only one JAR file: \" + dirPath);\n    } else if (Provider.SQLSERVER == provider) {\n      return files.stream().filter(f -> f.getName().startsWith(\"mssql-jdbc\")).findFirst()\n        .orElseThrow(() -> new MessageException(\"Directory does not contain JDBC driver: \" + dirPath)).getAbsolutePath();\n    }\n    return files.get(0).getAbsolutePath();\n  }\n\n  Provider resolveProviderAndEnforceNonnullJdbcUrl(Props props) {\n    String url = props.value(JDBC_URL.getKey());\n    Integer embeddedDatabasePort = props.valueAsInt(JDBC_EMBEDDED_PORT.getKey());\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java#L66-L102","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (config points at missing dir)\njdbcProviderPath = \"extensions/jdbc-driver/postgres\"\n// after\nmkdir -p $SONARQUBE_HOME/extensions/jdbc-driver/postgres  # or fix the configured path","handlingStrategy":"validation","validationCode":"File dir = new File(homeDir, providerPath);\nif (!dir.isDirectory()) throw new IllegalStateException(\"Driver directory missing: \" + dir.getAbsolutePath());","typeGuard":"static boolean validDriverDir(File homeDir, String path) { File d = new File(homeDir, path); return d.exists() && d.isDirectory(); }","tryCatchPattern":"try { settings.start(); } catch (MessageException e) { if (e.getMessage().startsWith(\"Directory does not exist\")) { /* fix config or create dir */ } throw e; }","preventionTips":["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"],"tags":["filesystem","jdbc","configuration","sonarqube"],"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-14T05:17:10.506Z"}