quarkusio/quarkus · error · DefinitionException
Multiple disposed parameters found for ${disposerMethod}
Error message
Multiple disposed parameters found for ${disposerMethod} What it means
ArC (Quarkus's CDI implementation) requires that a disposer method has exactly one disposed parameter — the parameter annotated @Disposes. This DefinitionException is thrown at build time when a disposer method declares two or more @Disposes-annotated parameters, which is illegal per the CDI specification.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/DisposerInfo.java:103
}
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
- Keep exactly one @Disposes-annotated parameter per disposer method; remove the extra @Disposes annotation or split into separate disposer methods
- If you intended to dispose two different beans, write one disposer method per producer/bean
- Verify the @Disposes import is jakarta.enterprise.inject.Disposes and it was not accidentally duplicated by an IDE quick-fix
Example fix
// before
void dispose(@Disposes DbConnection c, @Disposes DbConnection c2) { ... }
// after
void dispose(@Disposes DbConnection c) { ... } Defensive patterns
Strategy: validation
Validate before calling
long disposedCount = java.util.Arrays.stream(disposerMethod.getParameters())
.filter(p -> p.isAnnotationPresent(jakarta.enterprise.inject.Disposes.class)).count();
if (disposedCount != 1) throw new IllegalStateException("Disposer must have exactly one @Disposes parameter: " + disposerMethod); Prevention
- Exactly one @Disposes parameter per disposer method
- Additional parameters must be @Binding-qualified for lookup, never @Disposes
- Run a Quarkus build early — ArC catches this at build time
When it happens
Trigger: Declaring a disposer method with more than one parameter annotated @Disposes, e.g. void dispose(@Disposes A a, @Disposes B b).
Common situations: Copy-paste of a disposer for a second bean type inside one method; refactoring where an old disposed parameter was left behind; misunderstanding that the @Disposes annotation marks the single disposed parameter.
Related errors
- No TCCL available
- Unsupported value:
- Unable to construct type for ${btRemovedBean}: ${e.getMessag
- Invalid injection of Interceptor<T> bean, can only be used i
- Invalid injection of @Intercepted Bean<T>, can only be injec
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/5b922aed0d4a6aef.
Report an issue: GitHub.