pentaho/pentaho-kettle · error · IllegalStateException

Failed to create repository for user

Error message

Failed to create repository for user: ${sessionName}

What it means

connect delegates actual repository creation to delegate.connect(repositoryName) inside a cache-loader (getOrCreateFromRegionCache). If the delegate throws a KettleException, it is wrapped in an IllegalStateException carrying 'Failed to create repository for user: <sessionName>'; the outer code unwraps and rethrows the original KettleException when the cause is one. This message indicates repository construction failed for the given user.

Solutions

  1. Inspect the chained cause (KettleException) for the real failure and fix it first.
  2. Verify the repository name exists in repositories.xml (repositoriesMeta.findRepository).
  3. Test connectivity to the underlying database/server repository manually.
  4. Clear the per-user repository cache region if a poisoned entry persists after fixing the cause.

Example fix

// before
} catch (IllegalStateException e) { log.error(e.getMessage()); }
// after
} catch (IllegalStateException e) {
  if (e.getCause() instanceof KettleException ke) {
    log.error("Root cause: ", ke); // inspect real failure
  }
}
Defensive patterns

Strategy: try-catch

Try / catch

try { repo = factory.connect(name); }
catch (KettleException e) { Throwable root = e; while (root.getCause() != null) root = root.getCause(); log.error("Repository creation failed", root); }

Prevention

When it happens

Trigger: Calling connect when delegate.connect fails for any reason — bad repositories.xml, repository unreachable, plugin load failure — while a valid session exists; the user name in the message comes from the active session.

Common situations: Wrong repository name; KettleDatabaseRepository missing database driver; network/VPN down to the repository DB; corrupted $HOME/.kettle/repositories.xml.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at plugins/pur/core/src/main/java/org/pentaho/di/repository/utils/IRepositoryFactory.java:95

    @Override
    public Repository connect( String repositoryName ) throws KettleException {

      IPentahoSession session = PentahoSessionHolder.getSession();
      if ( session == null ) {
        logger.debug( "No active Pentaho Session, attempting to load PDI repository unauthenticated." );
        throw new KettleException( "Attempting to create PDI Repository with no Active PentahoSession. "
            + "This is not allowed." );
      }
      ICacheManager cacheManager = PentahoSystem.getCacheManager( session );

      String sessionName = session.getName();
      try {
        return (Repository) cacheManager.getOrCreateFromRegionCache( REGION, sessionName, () -> {
          logger.debug( "Repository not cached for user: " + sessionName + ". Creating new Repository." );
          try {
            return delegate.connect( repositoryName );
          } catch ( KettleException e ) {
            throw new IllegalStateException( "Failed to create repository for user: " + sessionName, e );
          }
        } );
      } catch ( IllegalStateException e ) {
        if ( e.getCause() instanceof KettleException kettleException ) {
          throw kettleException;
        }
        throw e;
      }
    }
  }

  /**
   * Default implementation of the RepositoryFactory. Code moved from PDIImportUtil here pretty much as-is.
   */
  class DefaultRepositoryFactory implements IRepositoryFactory {
    private String repositoryId = "PentahoEnterpriseRepository";

    @Override

View on GitHub (pinned to f3058517a1)