pentaho/pentaho-kettle · error · RuntimeException

The function call getLastModifiedTime throw an error : +…

Error message

The function call getLastModifiedTime throw an error :  + e.toString()

What it means

getLastModifiedTime() wraps IOExceptions from VFS resolution or file.getContent().getLastModifiedTime() into this RuntimeException, appending e.toString(). The argument reached the VFS layer but IO failed — bad URI, provider missing, remote backend error, or content access failure.

Solutions

  1. Read the appended IOException detail for the precise cause.
  2. Correct the URI form (forward slashes, file:/// scheme on Windows, escaped chars).
  3. Verify remote connectivity, credentials, and installed VFS provider plugins.
  4. Add retry at the transformation level for transient remote errors.
  5. Consider reading lastModified via java.io.File (file.lastModified()) for local files to bypass VFS.

Example fix

// before
var ts = getLastModifiedTime( 'C:\\tmp\\a.txt' ); // bad URI -> IOException
// after
var f = new java.io.File('C:/tmp/a.txt');
var ts = new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format( new java.util.Date( f.lastModified() ) );
Defensive patterns

Strategy: try-catch

Validate before calling

var uri = String(path).replace(/\\/g, '/');
if (/^[A-Za-z]:/.test(uri)) { uri = 'file:///' + uri; }

Type guard

function isUriLike(v){ return typeof v === 'string' && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(v); }

Try / catch

try { var ts = getLastModifiedTime(path, fmt); } catch (e) { Logger.logError('getLastModifiedTime IO failure: ' + e); var ts = ''; }

Prevention

When it happens

Trigger: Malformed VFS URI/scheme; file.getContent() throwing on a remote provider (network blip, expired session); unsupported scheme without provider plugin; permission errors surfaced as IOException.

Common situations: SFTP/S3 jobs failing intermittently mid-run; Windows-style paths on the VFS; reading timestamps from a mounted share that dropped during the run.

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/8d9bf18bac9e42ee. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:2364

          // Source file
          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
          String dateformat = (String) ArgList[1];
          if ( isNull( dateformat ) ) {
            dateformat = "yyyy-MM-dd";
          }
          String lastmodifiedtime = null;
          if ( file.exists() ) {
            java.util.Date lastmodifiedtimedate = new java.util.Date( file.getContent().getLastModifiedTime() );
            java.text.DateFormat dateFormat = new SimpleDateFormat( dateformat );
            lastmodifiedtime = dateFormat.format( lastmodifiedtimedate );

          } else {
            throw new RuntimeException( "file [" + ArgList[0] + "] can not be found!" );
          }

          return lastmodifiedtime;
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call getLastModifiedTime throw an error : " + e.toString() );
        } finally {
          if ( file != null ) {
            try {
              file.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

      } else {
        throw new RuntimeException( "The function call getLastModifiedTime is not valid." );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e.toString() );
    }
  }

View on GitHub (pinned to f3058517a1)