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
- Check and grant delete (write) permissions on the file and its containing directory for the user running PDI.
- Close any application holding the file open (check with lsof/handle) or stop the locking process.
- Ensure the mount/filesystem is writable (not read-only) and the service account has rights.
- Run the transformation as a user with sufficient OS-level privileges; on shared/NFS storage verify export permissions.
- 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
- Run PDI as a user with write access to the source directories
- Ensure no other process holds the files open during the run
- Check mount read-only status and NFS/SMB permissions
- Use 'simulate' mode first to verify which files would be deleted
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
- Could not delete stale file " + buildFilename
- GetSubFolders.Exception.NoAccessibleFiles
- JsonOutput.Error.ErrorCreatingParentFolder
- JsonOutput.Error.OpenNewFile
- AbsSecurityManager.ERROR_0005_INSUFFICIENT_PRIVELEGES
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)