{"record":{"id":"3865fbee5132da59","repo":"pentaho/pentaho-kettle","slug":"we-can-not-find-file","errorCode":null,"errorMessage":"We can not find file []!","messagePattern":"We can not find file \\[\\]!","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":5294,"sourceCode":"   * Execute an SQL statement inside a file on the database connection (has to be open)\n   *\n   * @param filename The file that contains SQL to execute\n   * @return a Result object indicating the number of lines read, deleted, inserted, updated, ...\n   * @throws KettleDatabaseException in case anything goes wrong.\n   * @sendSinglestatement send one statement\n   */\n  public Result execStatementsFromFile( Bowl bowl, String filename, boolean sendSinglestatement )\n    throws KettleException {\n    FileObject sqlFile = null;\n    InputStream is = null;\n    InputStreamReader bis = null;\n    try {\n      if ( Utils.isEmpty( filename ) ) {\n        throw new KettleException( \"Filename is missing!\" );\n      }\n      sqlFile = KettleVFS.getInstance( bowl ).getFileObject( filename );\n      if ( !sqlFile.exists() ) {\n        throw new KettleException( \"We can not find file [\" + filename + \"]!\" );\n      }\n\n      is = KettleVFS.getInputStream( sqlFile );\n      bis = new InputStreamReader( new BufferedInputStream( is, 500 ) );\n\n      BufferedReader buff = new BufferedReader( bis );\n      String sLine;\n      StringBuilder sql = new StringBuilder( Const.CR );\n\n      while ( ( sLine = buff.readLine() ) != null ) {\n        if ( Utils.isEmpty( sLine ) ) {\n          sql.append( Const.CR );\n        } else {\n          sql.append( Const.CR ).append( sLine );\n        }\n      }\n\n      if ( sendSinglestatement ) {","sourceCodeStart":5276,"sourceCodeEnd":5312,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L5276-L5312","documentation":"Database.execStatementsFromFile() (execSqlFile path) throws this when the SQL script file resolved via KettleVFS does not exist on the filesystem/VFS layer. It is thrown after the filename emptiness check, so the name was provided but nothing exists at that path. The library deliberately fails fast instead of proceeding to open an input stream.","triggerScenarios":"Calling Database.execStatementsFromFile (or SQL execution from file) with a filename that is non-empty but points to a missing file — wrong absolute path, file deleted before execution, or VFS scheme/URI resolution pointing elsewhere.","commonSituations":"Job/transformation configuration references an .sql file relative to a working directory that differs at runtime; file lives in a repo but not on the execution node; path uses Windows-style separators or unexpanded variables like ${Internal.Job.Filename.Directory}.","solutions":["Verify the file exists at the exact resolved path (ls/cat or VFS listing) before running the transformation.","Convert relative paths to absolute, ideally using kettle environment variables like ${Internal.Job.Filename.Directory} to build the path.","Check for typos, case sensitivity, and Windows vs Unix path separators.","Ensure the file is deployed to every execution node when running clustered.","If the file is intentionally optional, check existence (KettleVFS.getFileObject(f).exists()) before invoking."],"exampleFix":"// before\ndatabase.execStatementsFromFile(logChannel, sqlFilePath, false, true, null, charset);\n// after\nFileObject f = KettleVFS.getInstance(bowl).getFileObject(sqlFilePath);\nif (f == null || !f.exists()) { throw new IllegalStateException(\"SQL file missing: \" + sqlFilePath); }\ndatabase.execStatementsFromFile(logChannel, sqlFilePath, false, true, null, charset);","handlingStrategy":"validation","validationCode":"FileObject f = KettleVFS.getInstance(bowl).getFileObject(sqlFilePath);\nif (Utils.isEmpty(sqlFilePath) || f == null || !f.exists()) {\n  throw new IllegalArgumentException(\"SQL file not found: \" + sqlFilePath);\n}","typeGuard":"boolean sqlFileExists(String path) {\n  try { FileObject f = KettleVFS.getInstance(new Bowl()).getFileObject(path); return f != null && f.exists(); }\n  catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n  database.execStatementsFromFile(logChannel, path, false, true, null, charset);\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"We can not find file\")) {\n    // resolve absolute path, check deployment, retry once with corrected path\n  } else { throw e; }\n}","preventionTips":["Resolve relative paths against ${Internal.Job.Filename.Directory} before use.","Check file existence on every execution node in clustered setups.","Avoid hand-built paths with mixed separators; use VFS URIs."],"tags":["file","vfs","sql-script","path"],"backgroundTag":"file-not-found","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"}