pentaho/pentaho-kettle · error · KettleObjectExistsException

Failed to save object to repository. Object

Error message

Failed to save object to repository. Object [{name}] already exists.

What it means

KettleObjectExistsException thrown by saveClusterSchema when saving a cluster schema whose name collides with an existing repository object and overwrite=false. The delegate finds an existing cluster schema id under the same name; without overwrite permission it refuses to save. Passing overwrite=true would delete the old version and save the new one.

Solutions

  1. Call save with overwrite=true to replace the existing cluster schema
  2. Rename the cluster schema before saving to avoid the collision
  3. Delete the existing cluster schema explicitly via repository.deleteClusterSchema(existingId) first
  4. Catch KettleObjectExistsException and prompt the user for overwrite/rename

Example fix

// before
repository.save(clusterSchema, "Version", new Date(), false); // throws if name exists

// after
repository.save(clusterSchema, "Version", new Date(), true); // overwrite existing
Defensive patterns

Strategy: validation

Validate before calling

ObjectId existing = repository.getClusterSchemaID(clusterSchema.getName()); if (existing != null && !overwriteAllowed) { throw new IllegalStateException("Cluster schema name in use: " + clusterSchema.getName()); }

Type guard

boolean nameInUse = repository.getClusterSchemaID(name) != null;

Try / catch

try { repository.save(clusterSchema, label, date, false); } catch (KettleObjectExistsException e) { /* prompt user: overwrite or rename */ }

Prevention

When it happens

Trigger: repository.save(clusterSchema, versionLabel, date) resolving to saveClusterSchema(overwrite=false) while getClusterSchemaID(name) returns a non-null id for a different object with the same name.

Common situations: Importing transformations/jobs whose cluster schema names already exist in the target repository without enabling the import 'overwrite' option.

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/39606d856513bc15. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryClusterSchemaDelegate.java:116

    ObjectId existingClusterSchemaId = getClusterID( clusterSchema.getName() );
    if ( existingClusterSchemaId != null ) {
      clusterSchema.setObjectId( existingClusterSchemaId );
    }

    if ( clusterSchema.getObjectId() == null ) {
      // New Slave Server
      clusterSchema.setObjectId( insertCluster( clusterSchema ) );
    } else {

      // If we received a clusterSchemaId and it is different from the cluster schema we are working with...
      if ( existingClusterSchemaId != null && !clusterSchema.getObjectId().equals( existingClusterSchemaId ) ) {
        // A cluster with this name already exists
        if ( overwrite ) {
          // Proceed with save, removing the original version from the repository first
          repository.deleteClusterSchema( existingClusterSchemaId );
          updateCluster( clusterSchema );
        } else {
          throw new KettleObjectExistsException( "Failed to save object to repository. Object ["
            + clusterSchema.getName() + "] already exists." );
        }
      } else {
        // There are no naming collisions (either it is the same object or the name is unique)
        updateCluster( clusterSchema );
      }
    }

    repository.delClusterSlaves( clusterSchema.getObjectId() );

    // Also save the used slave server references.
    for ( int i = 0; i < clusterSchema.getSlaveServers().size(); i++ ) {
      SlaveServer slaveServer = clusterSchema.getSlaveServers().get( i );
      if ( slaveServer.getObjectId() == null ) {
        // oops, not yet saved!

        repository.save( slaveServer, versionComment, null, id_transformation, isUsedByTransformation, overwrite );
      }

View on GitHub (pinned to f3058517a1)