apache/beam · error · IllegalStateException

Could not create catalog

Error message

Could not create catalog '%s': expected only one implementation for type '%s' but found %s

What it means

findAndCreateCatalog resolves catalog implementations via ServiceLoader (CatalogRegistrar). This guard fires when more than one registered Catalog class claims the requested type string, making the choice ambiguous, and creation is aborted with IllegalStateException.

Solutions

  1. Ensure only one catalog implementation of the given type is on the classpath; remove or de-register the duplicate registrar.
  2. Use a more specific/unambiguous type string that maps to exactly one registered catalog.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/catalog/InMemoryCatalogManager.java:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/8b02fb3ae5ccc7aa. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/catalog/InMemoryCatalogManager.java:110

    return tableProviders;
  }

  private Catalog findAndCreateCatalog(String name, String type, Map<String, String> properties) {
    ImmutableList.Builder<Catalog> list = ImmutableList.builder();
    for (CatalogRegistrar catalogRegistrar :
        ServiceLoader.load(CatalogRegistrar.class, getClass().getClassLoader())) {
      for (Class<? extends Catalog> catalogClass : catalogRegistrar.getCatalogs()) {
        Catalog catalog = createCatalogInstance(catalogClass, name, properties);
        if (catalog.type().equalsIgnoreCase(type)) {
          list.add(catalog);
        }
      }
    }

    List<Catalog> foundCatalogs = list.build();

    if (foundCatalogs.size() > 1) {
      throw new IllegalStateException(
          String.format(
              "Could not create catalog '%s': "
                  + "expected only one implementation for type '%s' but found %s",
              name, type, foundCatalogs.size()));
    } else if (foundCatalogs.isEmpty()) {
      throw new UnsupportedOperationException(
          String.format("Could not find type '%s' for catalog '%s'.", type, name));
    }

    return foundCatalogs.get(0);
  }

  private Catalog createCatalogInstance(
      Class<? extends Catalog> catalogClass, String name, Map<String, String> properties) {
    try {
      return catalogClass.getConstructor(String.class, Map.class).newInstance(name, properties);
    } catch (ReflectiveOperationException e) {
      throw new RuntimeException(

View on GitHub (pinned to 12126d8942)