pentaho/pentaho-kettle · error · KettleDatabaseException

JobSQL.SQLFileNotExist

JobSQL.SQLFileNotExist

Error message

JobSQL.SQLFileNotExist

What it means

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.

Solutions

  1. Verify the file exists at the exact path on the machine executing the job.
  2. Check that all environment variables in the filename resolve at runtime (log the substituted path).
  3. Use an absolute path or ${Internal.Job.Filename.Directory} based relative path.
  4. Ensure the file is deployed/accessible to the execution server and readable by the service user.

Example fix

// before
sqlEntry.setSqlFilename("init.sql"); // relative, breaks when run from another dir
// after
sqlEntry.setSqlFilename("${Internal.Job.Filename.Directory}/init.sql");
Defensive patterns

Strategy: validation

Validate before calling

JobEntrySQL sqlEntry = (JobEntrySQL) jobEntry;
String real = sqlEntry.environmentSubstitute(sqlEntry.getSqlFilename());
File f = new File(real);
if (!f.exists() || !f.isFile()) {
  throw new KettleException("SQL file does not exist: " + real);
}

Try / catch

try {
  result = sqlEntry.execute(prev, 0);
} catch (KettleDatabaseException e) {
  if (e.getMessage() != null && e.getMessage().contains("SQLFileNotExist")) {
    logError("SQL file missing at runtime; check path/variables on the executing host");
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/86c2bcf60f3bcc93. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java:280

    } else {
      result.setNrErrors( 1 );
      logError( BaseMessages.getString( PKG, "JobSQL.NoDatabaseConnection" ) );
    }

    result.setResult( result.getNrErrors() == 0 );
    return result;
  }

  public String buildSqlFromFile() throws KettleDatabaseException {
    if ( sqlFilename == null ) {
      throw new KettleDatabaseException( BaseMessages.getString( PKG, "JobSQL.NoSQLFileSpecified" ) );
    }

    String realFilename = environmentSubstitute( sqlFilename );
    try ( FileObject sqlFile = KettleVFS.getInstance( parentJobMeta.getBowl() ).getFileObject( realFilename, this ) ) {
      if ( !sqlFile.exists() ) {
        logError( BaseMessages.getString( PKG, "JobSQL.SQLFileNotExist", realFilename ) );
        throw new KettleDatabaseException( BaseMessages.getString(
          PKG, "JobSQL.SQLFileNotExist", realFilename ) );
      }
      if ( isDetailed() ) {
        logDetailed( BaseMessages.getString( PKG, "JobSQL.SQLFileExists", realFilename ) );
      }

      try ( InputStream inputStream = KettleVFS.getInputStream( sqlFile ) ) {
        InputStreamReader bufferedStream = new InputStreamReader( new BufferedInputStream( inputStream, 500 ) );

        BufferedReader buff = new BufferedReader( bufferedStream );
        String sLine;
        StringBuilder sqlBuilder = new StringBuilder( Const.CR );

        while ( ( sLine = buff.readLine() ) != null ) {
          if ( Utils.isEmpty( sLine ) ) {
            sqlBuilder.append( Const.CR );
          } else {
            sqlBuilder.append( Const.CR ).append( sLine );

View on GitHub (pinned to f3058517a1)