{"record":{"id":"fa9fdd3fbb0a3025","repo":"quarkusio/quarkus","slug":"parameter-type-type-is-being-used-multiple-times","errorCode":null,"errorMessage":"Parameter type <type> is being used multiple times in method<method> of class<class>","messagePattern":"Parameter type <type> is being used multiple times in 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":100,"sourceCode":"     * and make sure it's supported\n     * The jakarta.ws.rs.ext.ExceptionMapper only has one parameter, the exception, however\n     * other parameters can be obtained using @Context and therefore injected into the target method\n     */\n    @Override\n    protected void preGenerateMethodBody(ClassCreator cc) {\n        if (!isResteasyClassic) {\n            return;\n        }\n\n        int notAllowedParameterIndex = -1;\n        for (int i = 0; i < parameterTypes.size(); i++) {\n            Type parameterType = parameterTypes.get(i);\n            DotName parameterTypeDotName = parameterType.name();\n            if (typesUtil.isAssignable(Exception.class, parameterTypeDotName)) {\n                // do nothing since this will be handled during in generateMethodBody\n            } else if (typesUtil.isAssignable(HttpServletRequest.class, parameterTypeDotName)) {\n                if (parameterTypeToField.containsKey(parameterType)) {\n                    throw new IllegalArgumentException(\"Parameter type \" + parameterTypes.get(notAllowedParameterIndex).name()\n                            + \" 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 HttpServletRequest into the class\n                FieldDesc httpRequestField = cc.field(\"httpServletRequest\", fc -> {\n                    fc.setType(HttpServletRequest.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, httpRequestField);\n            } else if (typesUtil.isAssignable(HttpServletResponse.class, parameterTypeDotName)) {\n                if (parameterTypeToField.containsKey(parameterType)) {\n                    throw new IllegalArgumentException(\"Parameter type \" + parameterTypes.get(notAllowedParameterIndex).name()\n                            + \" is being used multiple times in method\" + controllerAdviceMethod.name() + \" of class\"\n                            + controllerAdviceMethod.declaringClass().name());","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-web/core/deployment/src/main/java/io/quarkus/spring/web/deployment/ControllerAdviceExceptionMapperGenerator.java#L82-L118","documentation":"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.","triggerScenarios":"Declaring a Spring-style @ExceptionHandler method inside a @ControllerAdvice with two HttpServletRequest parameters (e.g. HttpServletRequest req1, HttpServletRequest req2).","commonSituations":"Migrating Spring ControllerAdvice code verbatim to Quarkus; accidentally duplicating a parameter when refactoring method signatures; IDE auto-complete adding the request twice.","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"],"exampleFix":"// before\n@ExceptionHandler(Exception.class)\nvoid handle(Exception e, HttpServletRequest req, HttpServletRequest req2) {...}\n// after\n@ExceptionHandler(Exception.class)\nvoid handle(Exception e, HttpServletRequest req) {...}","handlingStrategy":"validation","validationCode":"Set<Class<?>> seen = new HashSet<>();\nfor (Class<?> p : handlerParams) { if (!seen.add(p)) throw new IllegalStateException(\"Duplicate param type \" + p); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep at most one HttpServletRequest parameter per @ExceptionHandler method","Audit handler signatures after migrating from Spring","Uniqueness-check supported parameter types during code review"],"tags":["quarkus","spring-web","controlleradvice","build-time","invalid-signature"],"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-14T00:17:10.932Z"}