{"record":{"id":"e1edd27f2464cc71","repo":"quarkusio/quarkus","slug":"parameter-type-type-is-not-supported-for-method","errorCode":null,"errorMessage":"Parameter type <type> is not supported for method<method> of class<class>","messagePattern":"Parameter type <type> is not supported for method<method> of class<class>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-web/core/deployment/src/main/java/io/quarkus/spring/web/deployment/ControllerAdviceExceptionMapperGenerator.java","lineNumber":135,"sourceCode":"                            + \" is being used multiple times in method\" + controllerAdviceMethod.name() + \" of class\"\n                            + controllerAdviceMethod.declaringClass().name());\n                }\n\n                // we need to generate a field that injects the HttpServletResponse into the class\n                FieldDesc httpResponseField = cc.field(\"httpServletResponse\", fc -> {\n                    fc.setType(HttpServletResponse.class);\n                    fc.private_();\n                    fc.addAnnotation(Context.class);\n                });\n\n                // stash the fieldCreator in a map indexed by the parameter type so we can retrieve it later\n                parameterTypeToField.put(parameterType, httpResponseField);\n            } else {\n                notAllowedParameterIndex = i;\n            }\n        }\n        if (notAllowedParameterIndex >= 0) {\n            throw new IllegalArgumentException(\n                    \"Parameter type \" + parameterTypes.get(notAllowedParameterIndex).name() + \" is not supported for method\"\n                            + controllerAdviceMethod.name() + \" of class\" + controllerAdviceMethod.declaringClass().name());\n        }\n\n        createHttpHeadersField(cc);\n    }\n\n    private void createHttpHeadersField(ClassCreator classCreator) {\n        httpHeadersField = classCreator.field(\"httpHeaders\", fc -> {\n            fc.setType(HttpHeaders.class);\n            fc.private_();\n            fc.addAnnotation(Context.class);\n        });\n    }\n\n    @Override\n    void generateMethodBody(BlockCreator bc, Expr thisRef, Expr exceptionParam) {\n        if (isVoidType(returnType)) {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-web/core/deployment/src/main/java/io/quarkus/spring/web/deployment/ControllerAdviceExceptionMapperGenerator.java#L117-L153","documentation":"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.","triggerScenarios":"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.","commonSituations":"Migrating Spring @ControllerAdvice handlers verbatim; Spring-specific parameter types (WebRequest, HandlerMethod, Model) that Quarkus' generator does not support; leftover unused parameters from refactoring.","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"],"exampleFix":"// before\n@ExceptionHandler(Exception.class)\nvoid handle(Exception e, WebRequest request) {...}\n// after\n@ExceptionHandler(Exception.class)\nvoid handle(Exception e, HttpServletRequest req) {...}","handlingStrategy":"validation","validationCode":"for (Class<?> p : handlerParams) {\n  boolean ok = Exception.class.isAssignableFrom(p) || HttpServletRequest.class.isAssignableFrom(p)\n            || HttpServletResponse.class.isAssignableFrom(p);\n  if (!ok) throw new IllegalStateException(\"Unsupported @ControllerAdvice param: \" + p);\n}","typeGuard":"boolean isSupportedParam(Class<?> t) {\n  return Exception.class.isAssignableFrom(t)\n      || HttpServletRequest.class.isAssignableFrom(t)\n      || HttpServletResponse.class.isAssignableFrom(t);\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["quarkus","spring-web","controlleradvice","build-time","unsupported-parameter"],"backgroundTag":"unsupported-method-signature","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}