quarkusio/quarkus · error · IllegalArgumentException
Parameter type <type> is not supported for method<method> of
Error message
Parameter type <type> is not supported for method<method> of class<class>
What it means
After iterating the parameters of a @ControllerAdvice exception-handler method, preGenerateMethodBody throws IllegalArgumentException if any parameter was neither an Exception subtype, HttpServletRequest, nor HttpServletResponse — those are the only parameter types the generated exception mapper can supply. The deployment fails and names the unsupported type, method, and class.
Source
Thrown at extensions/spring-web/core/deployment/src/main/java/io/quarkus/spring/web/deployment/ControllerAdviceExceptionMapperGenerator.java:135
+ " is being used multiple times in method" + controllerAdviceMethod.name() + " of class"
+ controllerAdviceMethod.declaringClass().name());
}
// we need to generate a field that injects the HttpServletResponse into the class
FieldDesc httpResponseField = cc.field("httpServletResponse", fc -> {
fc.setType(HttpServletResponse.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, httpResponseField);
} else {
notAllowedParameterIndex = i;
}
}
if (notAllowedParameterIndex >= 0) {
throw new IllegalArgumentException(
"Parameter type " + parameterTypes.get(notAllowedParameterIndex).name() + " is not supported for method"
+ controllerAdviceMethod.name() + " of class" + controllerAdviceMethod.declaringClass().name());
}
createHttpHeadersField(cc);
}
private void createHttpHeadersField(ClassCreator classCreator) {
httpHeadersField = classCreator.field("httpHeaders", fc -> {
fc.setType(HttpHeaders.class);
fc.private_();
fc.addAnnotation(Context.class);
});
}
@Override
void generateMethodBody(BlockCreator bc, Expr thisRef, Expr exceptionParam) {
if (isVoidType(returnType)) {View on GitHub (pinned to e1c734241f)
Solutions
- Remove unsupported parameters, keeping only Exception subtypes, HttpServletRequest, and HttpServletResponse
- Replace Spring-specific types like WebRequest/HandlerMethod with HttpServletRequest equivalents
- Obtain extra data (e.g. session attributes) inside the method body from the injected request instead of via parameters
Example fix
// before
@ExceptionHandler(Exception.class)
void handle(Exception e, WebRequest request) {...}
// after
@ExceptionHandler(Exception.class)
void handle(Exception e, HttpServletRequest req) {...} Defensive patterns
Strategy: validation
Validate before calling
for (Class<?> p : handlerParams) {
boolean ok = Exception.class.isAssignableFrom(p) || HttpServletRequest.class.isAssignableFrom(p)
|| HttpServletResponse.class.isAssignableFrom(p);
if (!ok) throw new IllegalStateException("Unsupported @ControllerAdvice param: " + p);
} Type guard
boolean isSupportedParam(Class<?> t) {
return Exception.class.isAssignableFrom(t)
|| HttpServletRequest.class.isAssignableFrom(t)
|| HttpServletResponse.class.isAssignableFrom(t);
} Prevention
- Only use Exception, HttpServletRequest, HttpServletResponse as handler parameters
- Replace Spring-only types (WebRequest, Model, HandlerMethod) when migrating
- Fetch auxiliary data inside the method body via injected request
When it happens
Trigger: Declaring an @ExceptionHandler method with a parameter of an unsupported type, e.g. @ExceptionHandler(MyException.class) void handle(MyException e, Model model) or HttpSession, Principal, Locale, etc.
Common situations: Migrating Spring @ControllerAdvice handlers verbatim; Spring-specific parameter types (WebRequest, HandlerMethod, Model) that Quarkus' generator does not support; leftover unused parameters from refactoring.
Related errors
- Parameter type '<type>' is not supported for method '<method
- Parameter type <type> is being used multiple times in 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/e1edd27f2464cc71.
Report an issue: GitHub.