{"record":{"id":"86c2bcf60f3bcc93","repo":"pentaho/pentaho-kettle","slug":"jobsql-sqlfilenotexist","errorCode":"JobSQL.SQLFileNotExist","errorMessage":"JobSQL.SQLFileNotExist","messagePattern":"JobSQL\\.SQLFileNotExist","errorType":"error_code","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java","lineNumber":280,"sourceCode":"    } else {\n      result.setNrErrors( 1 );\n      logError( BaseMessages.getString( PKG, \"JobSQL.NoDatabaseConnection\" ) );\n    }\n\n    result.setResult( result.getNrErrors() == 0 );\n    return result;\n  }\n\n  public String buildSqlFromFile() throws KettleDatabaseException {\n    if ( sqlFilename == null ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"JobSQL.NoSQLFileSpecified\" ) );\n    }\n\n    String realFilename = environmentSubstitute( sqlFilename );\n    try ( FileObject sqlFile = KettleVFS.getInstance( parentJobMeta.getBowl() ).getFileObject( realFilename, this ) ) {\n      if ( !sqlFile.exists() ) {\n        logError( BaseMessages.getString( PKG, \"JobSQL.SQLFileNotExist\", realFilename ) );\n        throw new KettleDatabaseException( BaseMessages.getString(\n          PKG, \"JobSQL.SQLFileNotExist\", realFilename ) );\n      }\n      if ( isDetailed() ) {\n        logDetailed( BaseMessages.getString( PKG, \"JobSQL.SQLFileExists\", realFilename ) );\n      }\n\n      try ( InputStream inputStream = KettleVFS.getInputStream( sqlFile ) ) {\n        InputStreamReader bufferedStream = new InputStreamReader( new BufferedInputStream( inputStream, 500 ) );\n\n        BufferedReader buff = new BufferedReader( bufferedStream );\n        String sLine;\n        StringBuilder sqlBuilder = new StringBuilder( Const.CR );\n\n        while ( ( sLine = buff.readLine() ) != null ) {\n          if ( Utils.isEmpty( sLine ) ) {\n            sqlBuilder.append( Const.CR );\n          } else {\n            sqlBuilder.append( Const.CR ).append( sLine );","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java#L262-L298","documentation":"KettleDatabaseException with localized message JobSQL.SQLFileNotExist thrown by JobEntrySQL.buildSqlFromFile when the resolved SQL filename (after environment variable substitution) does not exist on the filesystem. It is logged as an error and thrown so the job entry fails.","triggerScenarios":"Executing a SQL job entry with sqlFromFile=true and sqlFilename set, but KettleVFS reports the file does not exist: wrong path, missing variable values at substitution time, wrong working directory, or file deleted between configuration and execution.","commonSituations":"Relative path that resolves differently on the executing server; environment variable like ${PROJECT_HOME} unset at runtime; file lives on a client machine but job runs on a remote Carte/Kettle server.","solutions":["Verify the file exists at the exact path on the machine executing the job.","Check that all environment variables in the filename resolve at runtime (log the substituted path).","Use an absolute path or ${Internal.Job.Filename.Directory} based relative path.","Ensure the file is deployed/accessible to the execution server and readable by the service user."],"exampleFix":"// before\nsqlEntry.setSqlFilename(\"init.sql\"); // relative, breaks when run from another dir\n// after\nsqlEntry.setSqlFilename(\"${Internal.Job.Filename.Directory}/init.sql\");","handlingStrategy":"validation","validationCode":"JobEntrySQL sqlEntry = (JobEntrySQL) jobEntry;\nString real = sqlEntry.environmentSubstitute(sqlEntry.getSqlFilename());\nFile f = new File(real);\nif (!f.exists() || !f.isFile()) {\n  throw new KettleException(\"SQL file does not exist: \" + real);\n}\n","typeGuard":null,"tryCatchPattern":"try {\n  result = sqlEntry.execute(prev, 0);\n} catch (KettleDatabaseException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"SQLFileNotExist\")) {\n    logError(\"SQL file missing at runtime; check path/variables on the executing host\");\n  }\n}","preventionTips":["Use ${Internal.Job.Filename.Directory} for relative SQL files","Verify variables resolve on the execution server, not just locally","Deploy SQL files to hosts where jobs actually run"],"tags":["file-not-found","pdi","job-entry","sql","filesystem"],"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"}