quarkusio/quarkus · error · DefinitionException

No producer method or field declared by the bean class that

Error message

No producer method or field declared by the bean class that is assignable to the disposed parameter of a disposer method: ${disposerMethod}

What it means

Every disposer method must correspond to a producer method or field declared by the same bean class, matching the disposed parameter type (assignable, with qualifiers). If a disposer is found whose disposed parameter matches no producer of its declaring bean, ArC throws this DefinitionException during bean registration.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java:1432

        // that are used, clearly a matching producer bean exists for those
        for (DisposerInfo unusedDisposer : unusedDisposers) {
            Type disposedParamType = unusedDisposer.getDisposedParameterType();
            boolean matchingProducerBeanExists = false;
            scan: for (BeanInfo bean : beans) {
                if (bean.isProducer()) {
                    if (!bean.getDeclaringBean().equals(unusedDisposer.getDeclaringBean())) {
                        continue;
                    }
                    for (Type beanType : bean.getTypes()) {
                        if (beanResolver.matches(disposedParamType, beanType)) {
                            matchingProducerBeanExists = true;
                            break scan;
                        }
                    }
                }
            }
            if (!matchingProducerBeanExists) {
                throw new DefinitionException("No producer method or field declared by the bean class that is assignable "
                        + "to the disposed parameter of a disposer method: " + unusedDisposer.getDisposerMethod());
            }
        }

        for (Entry<MethodInfo, Set<ClassInfo>> entry : syncObserverMethods.entrySet()) {
            registerObserverMethods(entry.getValue(), observers, injectionPoints,
                    beanClassToBean, entry.getKey(), false, observerTransformers, jtaCapabilities);
        }

        for (Entry<MethodInfo, Set<ClassInfo>> entry : asyncObserverMethods.entrySet()) {
            registerObserverMethods(entry.getValue(), observers, injectionPoints,
                    beanClassToBean, entry.getKey(), true, observerTransformers, jtaCapabilities);
        }

        if (LOGGER.isTraceEnabled()) {
            for (BeanInfo bean : beans) {
                LOGGER.logf(Level.TRACE, "Created %s", bean);
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Restore or re-add the matching @Produces method/field in the same bean class.
  2. Move the disposer into the class that declares the producer.
  3. Align the disposed parameter's type and qualifiers with the producer's.
  4. Delete the orphaned disposer method if it is no longer needed.

Example fix

// before
class Cfg {
  @Disposes
  void close(Conn c) { c.close(); } // no producer for Conn here
}
// after
class Cfg {
  @Produces
  Conn connect() { return new Conn(); }
  @Disposes
  void close(Conn c) { c.close(); }
}
Defensive patterns

Strategy: validation

Validate before calling

// Keep producer/disposer pairs in the same class; assert at build time
for (Method m : cls.getDeclaredMethods()) {
    if (Arrays.stream(m.getParameterAnnotations()).flatMap(Stream::of)
            .anyMatch(a -> a instanceof Disposes.class)
            && Arrays.stream(cls.getDeclaredMethods()).noneMatch(p -> p.isAnnotationPresent(Produces.class))) {
        throw new IllegalStateException("Disposer without producer in " + cls);
    }
}

Prevention

When it happens

Trigger: A @Disposes-annotated parameter's type/qualifiers cannot be matched to any @Produces method/field in the same class — e.g. the disposer references a producer that was deleted, moved to another class, renamed qualifiers, or is vetoed.

Common situations: Removing a producer method but keeping its disposer; moving producer/disposer pairs apart across classes; qualifier changes making the disposed parameter non-matching; unusedDisposer scan during deployment.

Related errors


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