pentaho/pentaho-kettle · error · KettleException

ProcessFiles.Error.CanNotDeleteFile

Error message

ProcessFiles.Error.CanNotDeleteFile

What it means

Thrown during OPERATION_TYPE_DELETE when data.sourceFile.delete() returns false, i.e. VFS could not delete the source file. Unlike exceptions, a false return means the file system refused or failed the delete without throwing (e.g. permission or lock).

Solutions

  1. Check and grant delete (write) permissions on the file and its containing directory for the user running PDI.
  2. Close any application holding the file open (check with lsof/handle) or stop the locking process.
  3. Ensure the mount/filesystem is writable (not read-only) and the service account has rights.
  4. Run the transformation as a user with sufficient OS-level privileges; on shared/NFS storage verify export permissions.
  5. Add step error handling so failed deletes are logged and retried later.

Example fix

// before
chmod 444 /data/in/file.txt
// after
chmod 644 /data/in/file.txt && chown pdiuser /data/in/file.txt
Defensive patterns

Strategy: try-catch

Validate before calling

// Guard: file exists and is writable before delete
java.io.File f = new java.io.File(sourceFilename);
boolean deletable = f.exists() && f.canWrite() && f.getParentFile().canWrite();

Type guard

boolean isDeletable(String path) {
  java.io.File f = (path == null) ? null : new java.io.File(path);
  return f != null && f.isFile() && f.canWrite() && f.getParentFile() != null && f.getParentFile().canWrite();
}

Try / catch

try {
  processRow();
} catch (KettleException e) {
  if (e.getMessage().contains("CanNotDeleteFile")) {
    logError("Delete failed (locked or permission denied): " + extractPath(e));
    // queue for retry
  } else throw e;
}

Prevention

When it happens

Trigger: Operation type Delete, simulate is false, and FileObject.delete() returns false for the resolved source file.

Common situations: File is read-only or owned by another user/process (insufficient permissions); file locked/open by another application (Windows); file on a read-only mount or protected system directory; VFS caching showing stale file state.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/processfiles/ProcessFiles.java:193

          if ( ( ( meta.isOverwriteTargetFile() && data.targetFile.exists() ) || !data.targetFile.exists() )
            && !meta.simulate ) {
            data.sourceFile.moveTo( KettleVFS.getInstance( getTransMeta().getBowl() )
                                    .getFileObject( targetFilename, getTransMeta() ) );
            if ( log.isDetailed() ) {
              logDetailed( BaseMessages.getString(
                PKG, "ProcessFiles.Log.SourceFileMoved", sourceFilename, targetFilename ) );
            }
          } else {
            if ( log.isDetailed() ) {
              logDetailed( BaseMessages.getString(
                PKG, "ProcessFiles.Log.TargetNotOverwritten", sourceFilename, targetFilename ) );
            }
          }
          break;
        case ProcessFilesMeta.OPERATION_TYPE_DELETE:
          if ( !meta.simulate ) {
            if ( !data.sourceFile.delete() ) {
              throw new KettleException( BaseMessages.getString(
                PKG, "ProcessFiles.Error.CanNotDeleteFile", data.sourceFile.toString() ) );
            }
          }
          if ( log.isDetailed() ) {
            logDetailed( BaseMessages.getString( PKG, "ProcessFiles.Log.SourceFileDeleted", sourceFilename ) );
          }
          break;
        default:

          break;
      }

      // add filename to result filenames?
      if ( meta.isaddTargetFileNametoResult()
        && meta.getOperationType() != ProcessFilesMeta.OPERATION_TYPE_DELETE
        && data.sourceFile.getType() == FileType.FILE ) {
        // Add this to the result file names...
        ResultFile resultFile =

View on GitHub (pinned to f3058517a1)