quarkusio/quarkus · error · IllegalArgumentException
Parameter type <type> is being used multiple times in method
Error message
Parameter type <type> is being used multiple times in method<method> of class<class>
What it means
ControllerAdviceExceptionMapperGenerator.preGenerateMethodBody validates parameters of a @ControllerAdvice exception-handler method it is turning into a generated mapper. HttpServletRequest parameters may appear at most once per method; a second occurrence makes field-injection generation ambiguous, so deployment fails with this IllegalArgumentException.
Source
Thrown at extensions/spring-web/core/deployment/src/main/java/io/quarkus/spring/web/deployment/ControllerAdviceExceptionMapperGenerator.java:100
* and make sure it's supported
* The jakarta.ws.rs.ext.ExceptionMapper only has one parameter, the exception, however
* other parameters can be obtained using @Context and therefore injected into the target method
*/
@Override
protected void preGenerateMethodBody(ClassCreator cc) {
if (!isResteasyClassic) {
return;
}
int notAllowedParameterIndex = -1;
for (int i = 0; i < parameterTypes.size(); i++) {
Type parameterType = parameterTypes.get(i);
DotName parameterTypeDotName = parameterType.name();
if (typesUtil.isAssignable(Exception.class, parameterTypeDotName)) {
// do nothing since this will be handled during in generateMethodBody
} else if (typesUtil.isAssignable(HttpServletRequest.class, parameterTypeDotName)) {
if (parameterTypeToField.containsKey(parameterType)) {
throw new IllegalArgumentException("Parameter type " + parameterTypes.get(notAllowedParameterIndex).name()
+ " is being used multiple times in method" + controllerAdviceMethod.name() + " of class"
+ controllerAdviceMethod.declaringClass().name());
}
// we need to generate a field that injects the HttpServletRequest into the class
FieldDesc httpRequestField = cc.field("httpServletRequest", fc -> {
fc.setType(HttpServletRequest.class);
fc.private_();
fc.addAnnotation(Context.class);
});
// stash the fieldCreator in a map indexed by the parameter type so we can retrieve it later
parameterTypeToField.put(parameterType, httpRequestField);
} else if (typesUtil.isAssignable(HttpServletResponse.class, parameterTypeDotName)) {
if (parameterTypeToField.containsKey(parameterType)) {
throw new IllegalArgumentException("Parameter type " + parameterTypes.get(notAllowedParameterIndex).name()
+ " is being used multiple times in method" + controllerAdviceMethod.name() + " of class"
+ controllerAdviceMethod.declaringClass().name());View on GitHub (pinned to e1c734241f)
Solutions
- Remove the duplicate HttpServletRequest parameter, keeping exactly one
- Verify all parameters of the handler method are unique among supported types (Exception, HttpServletRequest, HttpServletResponse)
- Refactor the handler so request state is read once and passed down locally
Example fix
// before
@ExceptionHandler(Exception.class)
void handle(Exception e, HttpServletRequest req, HttpServletRequest req2) {...}
// after
@ExceptionHandler(Exception.class)
void handle(Exception e, HttpServletRequest req) {...} Defensive patterns
Strategy: validation
Validate before calling
Set<Class<?>> seen = new HashSet<>();
for (Class<?> p : handlerParams) { if (!seen.add(p)) throw new IllegalStateException("Duplicate param type " + p); } Prevention
- Keep at most one HttpServletRequest parameter per @ExceptionHandler method
- Audit handler signatures after migrating from Spring
- Uniqueness-check supported parameter types during code review
When it happens
Trigger: Declaring a Spring-style @ExceptionHandler method inside a @ControllerAdvice with two HttpServletRequest parameters (e.g. HttpServletRequest req1, HttpServletRequest req2).
Common situations: Migrating Spring ControllerAdvice code verbatim to Quarkus; accidentally duplicating a parameter when refactoring method signatures; IDE auto-complete adding the request twice.
Related errors
- Parameter type <type> is not supported for method<method> of
- Parameter type '<type>' is not supported for method '<method
- @ExceptionHandler methods in @ControllerAdvice must be publi
- You can only have a single class annotated with @ControllerA
- Spring Web can only work if 'quarkus-resteasy-jackson' or 'q
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/fa9fdd3fbb0a3025.
Report an issue: GitHub.