pentaho/pentaho-kettle · error · KettleDatabaseException

JobSQL.ErrorRunningSQLfromFile

JobSQL.ErrorRunningSQLfromFile

Error message

JobSQL.ErrorRunningSQLfromFile

What it means

KettleDatabaseException with localized message JobSQL.ErrorRunningSQLfromFile thrown by JobEntrySQL.buildSqlFromFile as a catch-all for any Exception while reading the SQL file (after existence checks). It wraps I/O errors, permission problems, and encoding/parse issues encountered while building the SQL text.

Solutions

  1. Check the wrapped cause exception to identify the underlying I/O error.
  2. Verify the service user has read permission on the file and its directory.
  3. Confirm the network share/remote filesystem is reachable from the execution host.
  4. Re-validate the file (not locked, correct encoding) and retry the job.

Example fix

// before
File f = new File(path);
String sql = Files.readString(f.toPath()); // may throw on permission/IO
// after
File f = new File(path);
if (!f.canRead()) {
  logError("No read permission on SQL file: " + path);
}
String sql = Files.readString(f.toPath());
Defensive patterns

Strategy: try-catch

Validate before calling

String real = sqlEntry.environmentSubstitute(sqlEntry.getSqlFilename());
File f = new File(real);
if (!f.exists() || !f.canRead()) {
  throw new KettleException("SQL file missing or unreadable: " + real);
}

Try / catch

try {
  result = sqlEntry.execute(prev, 0);
} catch (KettleDatabaseException e) {
  logError("Error reading SQL file: " + e.getCause(), e); // cause holds the I/O detail
}

Prevention

When it happens

Trigger: Calling buildSqlFromFile when KettleVFS.getFileObject, opening the input stream, or line-by-line reading throws: file locked, no read permission, unsupported filesystem/URI, or IO error mid-read.

Common situations: File opened exclusively by another process; service account lacks read permission; file on an unreachable network share; wrong file content/encoding causing reader errors.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

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

      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 );
          }
        }
        return sqlBuilder.toString();
      }
    } catch ( Exception e ) {
      throw new KettleDatabaseException( BaseMessages.getString( PKG, "JobSQL.ErrorRunningSQLfromFile" ), e );
    }
  }

  public boolean evaluates() {
    return true;
  }

  public boolean isUnconditional() {
    return true;
  }

  public DatabaseMeta[] getUsedDatabaseConnections() {
    return new DatabaseMeta[] { databaseMeta, };
  }

  public List<ResourceReference> getResourceDependencies( JobMeta jobMeta ) {
    List<ResourceReference> references = super.getResourceDependencies( jobMeta );
    if ( databaseMeta != null ) {

View on GitHub (pinned to f3058517a1)