pentaho/pentaho-kettle · error · ReportProcessingException

ERROR_0001_TARGET_EXISTS

ERROR_0001_TARGET_EXISTS

Error message

ReportExportTask.ERROR_0001_TARGET_EXISTS

What it means

ReportExportTask.run() resolves the target file via KettleVFS and, if it already exists, attempts to delete it before rendering. If the delete fails, it throws ReportProcessingException with ReportExportTask.ERROR_0001_TARGET_EXISTS. The task cannot start writing the report while an unremovable file occupies the target path.

Solutions

  1. Close any application holding the target file open, then rerun the transformation
  2. Delete the target file manually and confirm the account running Kettle has delete permission on the directory
  3. Choose a different target filename/path in the step settings
  4. If targeting a remote VFS location, verify the provider supports delete and credentials allow it

Example fix

// before
if ( !targetFile.delete() ) {
  throw new ReportProcessingException( BaseMessages.getString( PKG, "ReportExportTask.ERROR_0001_TARGET_EXISTS" ) );
}
// after
if ( !targetFile.delete() ) {
  throw new ReportProcessingException( BaseMessages.getString( PKG,
    "ReportExportTask.ERROR_0001_TARGET_EXISTS" ) + " (" + targetPath + ")" );
}
Defensive patterns

Strategy: validation

Validate before calling

FileObject target = KettleVFS.getInstance( bowl ).getFileObject( targetPath );
if ( target.exists() && !target.delete() ) {
  throw new KettleException( "Target exists and cannot be deleted: " + targetPath );
}

Try / catch

try {
  exportTask.run();
} catch ( ReportProcessingException e ) {
  if ( e.getMessage().contains( "ERROR_0001" ) ) {
    logError( "Target file locked: " + targetPath );
  }
}

Prevention

When it happens

Trigger: targetFile.exists() is true and targetFile.delete() returns false — typically because the OS refuses the delete.

Common situations: Target PDF/Excel file is open in a viewer or editor holding a lock (common on Windows); file owned by another user without delete permission; target path is actually a non-empty directory; VFS provider cannot delete (e.g. remote filesystem restrictions).

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at plugins/pentaho-reporting/impl/src/main/java/org/pentaho/di/trans/steps/pentahoreporting/ReportExportTask.java:76

    this.targetPath = targetPath;
    this.createParentFolder = createParentFolder;
  }

  /**
   * When an object implementing interface <code>Runnable</code> is used to create a thread, starting the thread causes
   * the object's <code>run</code> method to be called in that separately executing thread.
   * <p/>
   * The general contract of the method <code>run</code> is that it may take any action whatsoever.
   *
   * @see Thread#run()
   */
  public void run() {
    try {
      targetFile = KettleVFS.getInstance( bowl ).getFileObject( targetPath );
      if ( targetFile.exists() ) {
        if ( !targetFile.delete() ) {
          throw new ReportProcessingException( BaseMessages.getString( PKG, "ReportExportTask.ERROR_0001_TARGET_EXISTS" ) );
        }
      }

      if ( createParentFolder ) {
        targetFile.getParent().createFolder();
      } else if ( !targetFile.getParent().exists() ) {
        throw new ReportProcessingException( BaseMessages.getString( PKG,
          "ReportExportTask.PARENT_FOLDER_DOES_NOT_EXIST", targetFile.getParent().getName().getPath() ) );
      }

      execute();
    } catch ( Exception ex ) {
      statusListener.setStatus( StatusType.ERROR, BaseMessages.getString( PKG,  "ReportExportTask.USER_EXPORT_FAILED" ), ex );
      logger.error( BaseMessages.getString( PKG, "ReportExportTask.ERROR.GenerationFailed", targetPath ) );
    }
  }

  protected void execute() throws Exception {

View on GitHub (pinned to f3058517a1)