quarkusio/quarkus · error · DefinitionException

No disposed parameters found for ${disposerMethod}

Error message

No disposed parameters found for ${disposerMethod}

What it means

A disposer method must have exactly one @Disposes-annotated parameter identifying what it disposes. DisposerInfo.initDisposedParam throws this DefinitionException when the disposer method has no @Disposes parameter at all.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DisposerInfo.java:101

        if (resultingQualifiers.isEmpty()) {
            resultingQualifiers.add(AnnotationInstance.builder(Default.class).build());
        }
        return resultingQualifiers;
    }

    Type getDisposedParameterType() {
        return disposerMethod.parameterType(disposedParameter.position());
    }

    MethodParameterInfo initDisposedParam(MethodInfo disposerMethod) {
        List<MethodParameterInfo> disposedParams = new ArrayList<>();
        for (AnnotationInstance annotation : disposerMethod.annotations()) {
            if (Kind.METHOD_PARAMETER == annotation.target().kind() && annotation.name().equals(DotNames.DISPOSES)) {
                disposedParams.add(annotation.target().asMethodParameter());
            }
        }
        if (disposedParams.isEmpty()) {
            throw new DefinitionException("No disposed parameters found for " + disposerMethod);
        } else if (disposedParams.size() > 1) {
            throw new DefinitionException("Multiple disposed parameters found for " + disposerMethod);
        }
        return disposedParams.get(0);
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Annotate exactly one parameter of the disposer method with @Disposes.
  2. Ensure that parameter's type matches the type produced by the corresponding @Produces method.
  3. If the method was not meant to be a disposer, remove any mismatched method parameters or move the method out of the producing bean.
  4. Verify only one parameter carries @Disposes (more than one triggers the sibling 'Multiple disposed parameters' error).

Example fix

// before
void close(Resource r) { r.shutdown(); } // missing @Disposes

// after
void close(@Disposes Resource r) { r.shutdown(); }
Defensive patterns

Strategy: validation

Validate before calling

long disposed = Arrays.stream(disposerMethod.getParameters())
    .filter(p -> p.isAnnotationPresent(jakarta.enterprise.inject.Disposes.class)).count();
if (disposed == 0) throw new IllegalStateException("Disposer must have one @Disposes parameter: " + disposerMethod);

Prevention

When it happens

Trigger: A method registered as a disposer (Arc found it during bean discovery as the disposer of a producer) has zero parameters annotated @Disposes — e.g. the annotation was forgotten, removed, or applied to the wrong method.

Common situations: Typing the disposer signature by hand and omitting @Disposes; moving the annotation to the wrong parameter; upgrading Arc/Quarkus where stricter validation catches an old signature; IDE auto-complete dropping the annotation.

Related errors


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