pentaho/pentaho-kettle · error · KettleException

ERROR_0004_REPOSITORY_NOT_FOUND

ERROR_0004_REPOSITORY_NOT_FOUND

Error message

RepositoryConnectionUtils.ERROR_0004_REPOSITORY_NOT_FOUND

What it means

While resolving the named repository inside connectToRepository, findRepository(repositoryName) (or the direct-index branch) is executed inside a try block; if lookup throws, the code rethrows a KettleException with ERROR_0004_REPOSITORY_NOT_FOUND including the repository name. It signals the requested repository definition does not exist in the loaded metadata.

Solutions

  1. List available repositories with new RepositoriesMeta().readData() and getRepository(i).getName(), then use an exact existing name.
  2. Register the repository in Spoon (Connect / Repository manager) or add it programmatically and call writeData().
  3. Check for exact name/case/whitespace match — findRepository compares strings literally.
  4. Verify you are reading the repositories.xml you think you are (HOME vs KETTLE_HOME differences).
  5. If using a direct repository index, confirm the supplied index is in range (the else-branch path).

Example fix

// before: hardcoded name that may not exist
Repository rep = RepositoryConnectionUtils.connectToRepository(log, null, "ProdRepo", user, pass, null, false);
// after: verify the name exists first
RepositoriesMeta rmi = new RepositoriesMeta();
rmi.readData();
if (rmi.findRepository("ProdRepo") == null) {
  throw new IllegalStateException("Available: " + IntStream.range(0, rmi.nrRepositories()).mapToObj(i -> rmi.getRepository(i).getName()).collect(Collectors.joining(", ")));
}
Repository rep = RepositoryConnectionUtils.connectToRepository(log, null, "ProdRepo", user, pass, null, false);
Defensive patterns

Strategy: validation

Validate before calling

RepositoriesMeta meta = new RepositoriesMeta();
meta.readData();
boolean exists = java.util.stream.IntStream.range(0, meta.nrRepositories()).anyMatch(i -> meta.getRepository(i).getName().equals(repoName));
if (!exists) throw new IllegalArgumentException("Unknown repository: " + repoName);

Try / catch

try { rep = RepositoryConnectionUtils.connectToRepository(...); } catch (KettleException e) { if (e.getMessage().contains("ERROR_0004")) { log.error("Repository name not found; check repositories.xml", e); } throw e; }

Prevention

When it happens

Trigger: Calling connectToRepository with a repositoryName that findRepository cannot match against the loaded RepositoriesMeta — typo'd name, repositories.xml lacking that entry, or an exception during lookup.

Common situations: Connecting programmatically after a fresh install where repositories.xml has no registered repositories; renamed repository in Spoon while scripts still use the old name; case-sensitivity mismatch in the repository name; CI servers pointing at a repository defined only on developers' machines.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/RepositoryConnectionUtils.java:99

      throw new KettleException( BaseMessages.getString(
        "RepositoryConnectionUtils.ERROR_0018_META_REPOSITORY_NOT_POPULATED" ), e ); //$NON-NLS-1$
    }

    if ( logger.isDebugEnabled() ) {
      logger.debug( " Finding repository metadata" );
    }
    // Find the specified repository.
    RepositoryMeta repositoryMeta = null;
    try {
      if ( isSingleDiServerInstance ) {
        repositoryMeta = repositoriesMeta.findRepository( SINGLE_DI_SERVER_INSTANCE );
      } else {
        repositoryMeta = repositoriesMeta.findRepository( repositoryName );
      }


    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG,
        "RepositoryConnectionUtils.ERROR_0004_REPOSITORY_NOT_FOUND", repositoryName ), e ); // $NON-NLS-1$
    }

    if ( repositoryMeta == null ) {
      if ( logger.isDebugEnabled() && logBuffer != null ) {
        logger.debug( logBuffer.getBuffer().toString() );
      }
      throw new KettleException( BaseMessages.getString( PKG,
        "RepositoryConnectionUtils.ERROR_0004_REPOSITORY_NOT_FOUND", repositoryName ) ); //$NON-NLS-1$
    }

    if ( logger.isDebugEnabled() ) {
      logger.debug( " Getting repository instance " ); //$NON-NLS-1$
    }
    Repository repository = null;
    try {
      repository =
        PluginRegistry.getInstance().loadClass( RepositoryPluginType.class, repositoryMeta.getId(),

View on GitHub (pinned to f3058517a1)