{"record":{"id":"f291106480d4d468","repo":"pentaho/pentaho-kettle","slug":"jdbcdriverresolver-cannot-convert-path-to-url","errorCode":null,"errorMessage":"JdbcDriverResolver: Cannot convert path to URL: \" + jarAbsolutePath","messagePattern":"JdbcDriverResolver: Cannot convert path to URL: \" \\+ jarAbsolutePath","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/JdbcDriverResolver.java","lineNumber":407,"sourceCode":"   * and has a {@code .jar} extension.\n   *\n   * @param jarAbsolutePath absolute path to the JAR file\n   * @return the file URL\n   * @throws KettleDatabaseException if the file does not exist, is not a regular file,\n   *                                  does not end with .jar, or cannot be converted\n   */\n  private static URL toJarUrl( String jarAbsolutePath ) throws KettleDatabaseException {\n    File jarFile = new File( jarAbsolutePath );\n    if ( !jarFile.exists() || !jarFile.isFile() ) {\n      throw new KettleDatabaseException( \"JdbcDriverResolver: JAR not found: \" + jarAbsolutePath );\n    }\n    if ( !jarFile.getName().toLowerCase().endsWith( \".jar\" ) ) {\n      throw new KettleDatabaseException( \"JdbcDriverResolver: not a JAR file: \" + jarAbsolutePath );\n    }\n    try {\n      return jarFile.toPath().toUri().toURL();\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"JdbcDriverResolver: Cannot convert path to URL: \" + jarAbsolutePath, e );\n    }\n  }\n}\n","sourceCodeStart":389,"sourceCodeEnd":411,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/JdbcDriverResolver.java#L389-L411","documentation":"Final guard in toJarUrl(): if File.toPath().toUri().toURL() throws (MalformedURLException or an invalid path/URI conversion, e.g. illegal characters or a path not expressible as a URI), the exception is wrapped in this KettleDatabaseException.","triggerScenarios":"jarAbsolutePath contains characters illegal in a URI/URL (spaces unencoded, non-ASCII or control characters, platform-specific oddities on Windows), causing toURL() to fail even though the file exists.","commonSituations":"Drivers directory path containing spaces or special characters; paths copied with trailing characters; Windows paths with unusual drive mappings inside containers.","solutions":["Remove illegal characters (spaces, '#', '%', non-ASCII) from the drivers directory path","Use a simple ASCII path without spaces for JDBC_DRIVERS_DIRECTORY","Read the cause for the exact MalformedURLException reason"],"exampleFix":"// before\nJDBC_DRIVERS_DIRECTORY=/opt/My Drivers/jdbc  # space breaks toURL()\n// after\nJDBC_DRIVERS_DIRECTORY=/opt/my-drivers/jdbc","handlingStrategy":"validation","validationCode":"try { new File( path ).toPath().toUri().toURL(); } catch ( Exception e ) { throw new IllegalStateException( \"path not URL-convertible: \" + path, e ); }","typeGuard":null,"tryCatchPattern":"try { toJarUrl( path ); } catch ( KettleDatabaseException e ) { if ( e.getMessage().contains( \"Cannot convert path to URL\" ) ) sanitizePathAndRetry( path ); throw e; }","preventionTips":["Use ASCII paths without spaces for driver directories","Quote/sanitize paths in deployment scripts","Standardize installation directories across environments"],"tags":["url","path","jdbc"],"backgroundTag":"invalid-url-format","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}