pentaho/pentaho-kettle · error · MetaStoreElementTypeExistsException

Can not create element type with id

Error message

Can not create element type with id '${elementType.id}' because it already exists

What it means

Thrown by PurRepositoryMetaStore.createElementType() when an element type with the same name already exists in the namespace (getElementTypeByName returns non-null). It is a MetaStoreElementTypeExistsException including the existing type; note the message text references the new type's id even though the collision is name-based.

Solutions

  1. Look up the type with getElementTypeByName first and reuse/update it instead of creating
  2. Catch MetaStoreElementTypeExistsException and fall back to the existing type
  3. Ensure idempotent initialization logic

Example fix

// before
metaStore.createElementType( ns, elementType );
// after
IMetaStoreElementType existing = metaStore.getElementTypeByName( ns, elementType.getName() );
if ( existing == null ) {
  metaStore.createElementType( ns, elementType );
} else {
  elementType.setId( existing.getId() );
}
Defensive patterns

Strategy: validation

Validate before calling

IMetaStoreElementType existing = metaStore.getElementTypeByName( ns, elementType.getName() );
if ( existing == null ) { metaStore.createElementType( ns, elementType ); } else { elementType.setId( existing.getId() ); }

Try / catch

try { metaStore.createElementType( ns, t ); } catch ( MetaStoreElementTypeExistsException e ) { t.setId( e.getElementType().getId() ); }

Prevention

When it happens

Trigger: Calling createElementType(namespace, elementType) when a type of the same name already exists under /etc/metastore/<namespace> — re-running registration code, or another client created the type concurrently.

Common situations: Plugin initialization that registers element types on every start; migration scripts run twice; two PDI instances open against the same repository.

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/78514d3aa1bbf16f. Report an issue: GitHub.

Appendix: source

Thrown at plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java:149

  public List<String> getNamespaces() throws MetaStoreException {
    List<String> namespaces = new ArrayList<String>();
    List<RepositoryFile> children = getChildren( namespacesFolder.getId() );
    for ( RepositoryFile child : children ) {
      namespaces.add( child.getName() );
    }
    return namespaces;
  }

  // The element types

  @Override
  public void createElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {

    RepositoryFile namespaceFile = validateNamespace( namespace );

    IMetaStoreElementType existingType = getElementTypeByName( namespace, elementType.getName() );
    if ( existingType != null ) {
      throw new MetaStoreElementTypeExistsException( Collections.singletonList( existingType ),
          "Can not create element type with id '" + elementType.getId() + "' because it already exists" );
    }

    RepositoryFile elementTypeFile =
        new RepositoryFile.Builder( elementType.getName() ).folder( true ).versioned( false ).build();

    RepositoryFile folder = pur.createFolder( namespaceFile.getId(), elementTypeFile, null );
    elementType.setId( folder.getId().toString() );

    // In this folder there is a hidden file which contains the description
    // and the other future properties of the element type
    //
    RepositoryFile detailsFile =
        new RepositoryFile.Builder( ELEMENT_TYPE_DETAILS_FILENAME ).folder( false ).title(
            ELEMENT_TYPE_DETAILS_FILENAME ).description( elementType.getDescription() ).hidden( true ).build();

    DataNode dataNode = getElementTypeDataNode( elementType );

View on GitHub (pinned to f3058517a1)