quarkusio/quarkus · error · AmbiguousResolutionException

multiple factory beans with type + type.getName() + found fo

Error message

multiple factory beans with type + type.getName() + found for keystore type '" + typeName + "'

What it means

Keystore types (PEM, PKCS12, JKS, other) are backed by factory beans looked up via an @Identifier qualifier named after the type string. lookupFactory throws AmbiguousResolutionException when two beans of the requested factory type carry the same identifier, because Arc cannot determine which factory should build the keystore.

Source

Thrown at extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java:269

                    "multiple beans with type " + type.getName() + " found for TLS configuration " + bucketName);
        }
        if (instances.isEmpty()) {
            return new InstanceHandle<T>() {
                @Override
                public T get() {
                    return null;
                }
            };
        }
        return instances.get(0);
    }

    static <T> InstanceHandle<T> lookupFactory(Class<T> type, String typeName) {
        var container = Arc.container();
        var qualifier = Identifier.Literal.of(typeName);
        var instances = container.listAll(type, qualifier);
        if (instances.size() > 1) {
            throw new AmbiguousResolutionException(
                    "multiple factory beans with type " + type.getName() + " found for keystore type '" + typeName + "'");
        }
        if (instances.isEmpty()) {
            return new InstanceHandle<T>() {
                @Override
                public T get() {
                    return null;
                }
            };
        }
        return instances.get(0);
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove or de-duplicate one of the conflicting factory beans so exactly one factory exists per keystore type name.
  2. Rename your custom factory's @Identifier (or use a distinct keystore type via 'other') so it no longer collides with the built-in factory.
  3. If the collision comes from a dependency, exclude its factory bean (e.g. do not bring in the library, or use an exclusion) so only your factory remains.

Example fix

// before
@ApplicationScoped
@Identifier("pkcs12")
class MyP12Factory implements KeyStoreFactory { ... }
// after
@ApplicationScoped
@Identifier("my-custom-pkcs12")
class MyP12Factory implements KeyStoreFactory { ... }
// and reference it via keystore config 'type' or the 'other' provider mechanism
Defensive patterns

Strategy: validation

Validate before calling

List<InstanceHandle<KeyStoreFactory>> factories = Arc.container()
    .listAll(KeyStoreFactory.class, Identifier.Literal.of("pkcs12"));
if (factories.size() > 1) {
    throw new IllegalStateException("More than one factory registered for keystore type 'pkcs12'");
}

Type guard

boolean hasUniqueFactory(Class<?> factoryType, String typeName) {
    return Arc.container().listAll(factoryType, Identifier.Literal.of(typeName)).size() == 1;
}

Try / catch

try {
    KeyStore ks = tlsConfig.getKeyStore();
} catch (AmbiguousResolutionException e) {
    log.error("Duplicate keystore factory beans; inspect @Identifier on factory classes", e);
}

Prevention

When it happens

Trigger: getKeyStore/getTrustStore resolving a keystore factory by typeName when two beans of that factory type are annotated with the same @Identifier(typeName).

Common situations: Shipping a custom factory for a keystore type (e.g. a custom PKCS12 factory) alongside Quarkus's built-in factory with the same @Identifier; including two extensions/libraries that each register a factory for the same type name; misconfigured @Identifier values (copy-paste leaving two beans with identical identifiers).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/7bf396fc5208f3d7. Report an issue: GitHub.