pentaho/pentaho-kettle · error

The function call getLastModifiedTime throw an error :

Error message

The function call getLastModifiedTime throw an error : 

What it means

getLastModifiedTime() reads the last-modified timestamp of the file named by its single argument through KettleVFS. When a java.io.IOException occurs while resolving the VFS file object or reading its metadata, the function rethrows it as a JavaScript runtime error: 'The function call getLastModifiedTime throw an error : ' followed by the exception text — an I/O-layer failure, not an argument-validation failure.

Solutions

  1. Confirm the path is a valid, fully-qualified VFS URI
  2. Verify filesystem reachability and valid credentials
  3. Check existence first with isFile()/isFolder() to isolate resolution failures
  4. Align/upgrade commons-vfs and provider dependencies

Example fix

// before
var t = getLastModifiedTime('hdfs:/namenode/data/f.csv'); // missing double slash
// after
var t = getLastModifiedTime('hdfs://namenode/data/f.csv');
Defensive patterns

Strategy: try-catch

Validate before calling

var f = isFile(path); // confirm the file resolves before reading metadata

Type guard

function isAbsoluteVfsPath(v) { return typeof v === 'string' && /^[a-z]+:\/\//.test(v); }

Try / catch

try { var t = getLastModifiedTime(path); } catch (e) {
  // 'getLastModifiedTime throw an error : <IOException>'
  t = null; }

Prevention

When it happens

Trigger: IOException from KettleVFS.getFileObject(path) or metadata reads on the FileObject — invalid/unreachable VFS URI, unsupported scheme/provider, network filesystem down, permission or resolution I/O errors.

Common situations: SFTP/S3/HDFS endpoints unreachable, expired credentials, unescaped characters breaking URI parsing, missing provider jars for the scheme, stale mounts in long-running transforms.

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/6ee1c7226f860b19. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2452

          // Source file
          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );
          String dateformat = Context.toString( 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 {
            Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
          }

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

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

View on GitHub (pinned to f3058517a1)