quarkusio/quarkus · error · DefinitionException

@BindingsSource may only define a class type, got ${kind}: $

Error message

@BindingsSource may only define a class type, got ${kind}: ${producerMethod}

What it means

When an InterceptionProxy parameter carries @BindingsSource, the annotation's value must be a class type (Kind.CLASS), since it names the class holding the interceptor bindings. Array, primitive, parameterized, or other type kinds are invalid, so ArC throws a DefinitionException during producer method creation.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java:213

        }

        InterceptionProxyInfo interceptionProxy = null;
        for (MethodParameterInfo parameter : producerMethod.parameters()) {
            if (parameter.type().name().equals(DotNames.INTERCEPTION_PROXY)) {
                if (interceptionProxy != null) {
                    throw new DefinitionException(
                            "Declaring more than one InterceptionProxy parameter is invalid: " + producerMethod);
                }
                if (parameter.type().kind() != Kind.PARAMETERIZED_TYPE) {
                    throw new DefinitionException(
                            "InterceptionProxy parameter must be a parameterized type: " + producerMethod);
                }
                DotName targetClass = producerMethod.returnType().name();
                DotName bindingsSource = null;
                if (parameter.hasAnnotation(DotNames.BINDINGS_SOURCE)) {
                    Type bindingsSourceType = parameter.annotation(DotNames.BINDINGS_SOURCE).value().asClass();
                    if (bindingsSourceType.kind() != Kind.CLASS) {
                        throw new DefinitionException("@BindingsSource may only define a class type, got "
                                + bindingsSourceType.kind() + ": " + producerMethod);
                    }
                    bindingsSource = bindingsSourceType.name();
                }
                interceptionProxy = new InterceptionProxyInfo(targetClass, bindingsSource);
            }
        }

        List<Injection> injections = Injection.forBean(producerMethod, declaringBean, beanDeployment, transformer,
                Injection.BeanType.PRODUCER_METHOD);
        BeanInfo bean = new BeanInfo(producerMethod, beanDeployment, scope, typeClosure.types(), qualifiers, injections,
                declaringBean, disposer, isAlternative, stereotypes, name, isDefaultBean, null, priority,
                typeClosure.unrestrictedTypes(), interceptionProxy);
        for (Injection injection : injections) {
            injection.init(bean);
        }
        return bean;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Change the @BindingsSource value to a plain class literal, e.g. @BindingsSource(MyBindings.class)
  2. Verify the class named by @BindingsSource exists and compiles
  3. Remove @BindingsSource if default bindings derived from the target type are sufficient

Example fix

// before
@Produces
MyService produce(InterceptionProxy<MyService> proxy) { ... }
// with @BindingsSource(value = SOMETHING_NOT_A_CLASS)
// after
@BindingsSource(MyBindings.class)
@Produces
MyService produce(InterceptionProxy<MyService> proxy) { ... }
Defensive patterns

Strategy: validation

Validate before calling

// before declaring
AnnotationInstance bs = param.annotation(DotNames.BINDINGS_SOURCE);
if (bs != null && bs.value().asClass().kind() != org.jboss.jandex.Type.Kind.CLASS) {
    throw new IllegalArgumentException("@BindingsSource value must be a class literal");
}

Try / catch

try {
    arcProcessor.validate(...);
} catch (DefinitionException e) {
    if (e.getMessage().contains("@BindingsSource may only define a class type")) {
        logger.errorf("Use a class literal for @BindingsSource: %s", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Beans.createProducerMethod processes an InterceptionProxy parameter annotated @BindingsSource whose annotation value resolves to a Type whose kind() != Kind.CLASS (e.g. an array or nested parameterized type was used as the value).

Common situations: Writing @BindingsSource(someArrayOrComplexConstant) by mistake; refactoring that changed the @BindingsSource value from a class literal to another annotation member; generated code emitting non-class values.

Related errors


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