pentaho/pentaho-kettle · error · RuntimeException

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

Error message

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

What it means

This is moveFile's IOException handler: any filesystem/VFS error during the move (destination unwritable, directory missing, locked file, permission denied) is rethrown as a RuntimeException whose message concatenates e.toString(). The underlying exception class and message are preserved but the stack trace is lost.

Solutions

  1. Read the embedded e.toString() to get the real VFS FileSystemException and its file/reason
  2. Create the destination directory before moving (e.g. via createParentFolder or an earlier step)
  3. Check filesystem permissions for the user executing the transformation
  4. Retry on transient network/SFTP failures; ensure no other process holds the source file open

Example fix

// before
moveFile(src, '/data/out/file.txt', true); // /data/out may not exist
// after
if (!folderExists('/data/out')) createFolder('/data/out');
moveFile(src, '/data/out/file.txt', true);
Defensive patterns

Strategy: try-catch

Validate before calling

// best-effort pre-checks in script
if (fileExists(src) && folderExists(dst.substring(0, dst.lastIndexOf('/')))) {
  moveFile(src, dst, true);
}

Try / catch

try {
  moveFile(src, dst, true);
} catch (e) {
  var cause = String(e.message); // contains underlying VFS exception toString()
  Logger.logError('moveFile failed: ' + cause);
  if (cause.indexOf('FileSystemException') >= 0) {
    // permission/lock/network issue: alert or retry
  }
}

Prevention

When it happens

Trigger: An IOException is raised by fileSource.moveTo(fileDestination) or by resolving file objects — destination directory does not exist, no write permission, file locked by another process, network share unreachable.

Common situations: Destination folder not created beforehand; running transformation as a service account lacking write rights on the target dir; moving files over SFTP when the connection drops; Windows file locks from another process holding the source open; message like 'The function call moveFile throw an error : org.apache.commons.vfs2.FileSystemException: ...'.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

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

            // Source file exists...
            if ( fileSource.getType() == FileType.FILE ) {
              // Great..source is a file ...
              boolean overwrite = false;
              if ( !ArgList[1].equals( null ) ) {
                overwrite = (Boolean) ArgList[2];
              }
              boolean destinationExists = fileDestination.exists();
              // Let's move the file...
              if ( ( destinationExists && overwrite ) || !destinationExists ) {
                fileSource.moveTo( fileDestination );
              }

            }
          } else {
            throw new RuntimeException( "file to move [" + ArgList[0] + "] can not be found!" );
          }
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call moveFile throw an error : " + e.toString() );
        } finally {
          if ( fileSource != null ) {
            try {
              fileSource.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
          if ( fileDestination != null ) {
            try {
              fileDestination.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

      } else {

View on GitHub (pinned to f3058517a1)