{"record":{"id":"f7924012489d53ae","repo":"quarkusio/quarkus","slug":"parameter-i-of-the-constructor-of-class-res","errorCode":null,"errorMessage":"Parameter: ${i} of the constructor of class '${resourceDotName}' contains multiple JAX-RS annotations, which is not valid","messagePattern":"Parameter: (.+?) of the constructor of class '(.+?)' contains multiple JAX-RS annotations, which is not valid","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CustomResourceProducersGenerator.java","lineNumber":245,"sourceCode":"                List<CtorParamData> ctorParamData = new ArrayList<>(ctor.parametersCount());\n                for (short i = 0; i < ctor.parametersCount(); i++) {\n                    Type parameterType = ctor.parameterType(i);\n                    if (!paramIndexToAnnotations.containsKey(i)) {\n                        ctorParamData.add(new CtorParamData(CtorParamData.CustomProducerParameterType.OTHER, parameterType));\n                    } else {\n                        List<AnnotationInstance> paramAnnotations = paramIndexToAnnotations.get(i);\n                        List<AnnotationInstance> jaxRSAnnotationsOfParam = new ArrayList<>(paramAnnotations.size());\n                        for (AnnotationInstance paramAnnotation : paramAnnotations) {\n                            if (ResteasyReactiveDotNames.RESOURCE_CTOR_PARAMS_THAT_NEED_HANDLING\n                                    .contains(paramAnnotation.name())) {\n                                jaxRSAnnotationsOfParam.add(paramAnnotation);\n                            }\n                        }\n                        if (jaxRSAnnotationsOfParam.isEmpty()) {\n                            ctorParamData\n                                    .add(new CtorParamData(CtorParamData.CustomProducerParameterType.OTHER, parameterType));\n                        } else if (jaxRSAnnotationsOfParam.size() > 1) {\n                            throw new IllegalArgumentException(\"Parameter: \" + i + \" of the constructor of class '\"\n                                    + resourceDotName + \"' contains multiple JAX-RS annotations, which is not valid\");\n                        } else {\n                            AnnotationInstance jaxRSAnnotationOfParam = jaxRSAnnotationsOfParam.iterator().next();\n                            if (!parameterType.name().equals(ResteasyReactiveDotNames.STRING)) {\n                                // TODO: do we need to support converters here?\n                                throw new IllegalArgumentException(\"Parameter: \" + i + \" of the constructor of class '\"\n                                        + resourceDotName + \"' which is annotated with '\" + jaxRSAnnotationOfParam.name()\n                                        + \"' can only be of type String\");\n                            }\n                            CtorParamData.CustomProducerParameterType customProducerParameterType;\n                            if (jaxRSAnnotationOfParam.name().equals(ResteasyReactiveDotNames.QUERY_PARAM)) {\n                                customProducerParameterType = CtorParamData.CustomProducerParameterType.QUERY;\n                            } else if (jaxRSAnnotationOfParam.name().equals(ResteasyReactiveDotNames.HEADER_PARAM)) {\n                                customProducerParameterType = CtorParamData.CustomProducerParameterType.HEADER;\n                            } else if (jaxRSAnnotationOfParam.name().equals(ResteasyReactiveDotNames.PATH_PARAM)) {\n                                customProducerParameterType = CtorParamData.CustomProducerParameterType.PATH;\n                            } else if (jaxRSAnnotationOfParam.name().equals(ResteasyReactiveDotNames.MATRIX_PARAM)) {\n                                customProducerParameterType = CtorParamData.CustomProducerParameterType.MATRIX;","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CustomResourceProducersGenerator.java#L227-L263","documentation":"Quarkus RESTEasy Reactive generates CDI producers for resource classes that have non-default constructors, so constructor parameters annotated with JAX-RS parameter annotations (@QueryParam, @PathParam, @MatrixParam, @CookieParam) can be resolved from the request. Each constructor parameter may carry at most ONE such JAX-RS annotation; when the generator finds two or more on the same parameter it aborts deployment with this IllegalArgumentException.","triggerScenarios":"A @Path resource class has a non-default constructor and one constructor parameter is annotated with two or more JAX-RS parameter annotations simultaneously (e.g. both @QueryParam and @PathParam on the same parameter). Detected during the Quarkus build when CustomResourceProducersGenerator.generate() processes the constructor.","commonSituations":"Copy-pasting annotations between parameters, refactoring a method signature into a constructor and accidentally stacking annotations, or mixing @PathParam with @QueryParam when a resource is served from multiple sub-locations.","solutions":["Keep exactly one JAX-RS parameter annotation per constructor parameter","Move extra parameter values to method-level @PathParam/@QueryParam injection on the resource method instead of the constructor","If a value is needed in two forms, inject it once in the constructor and derive the other in the class body"],"exampleFix":"// before\npublic MyResource(@QueryParam(\"q\") @PathParam(\"id\") String value) { ... }\n// after\npublic MyResource(@QueryParam(\"q\") String value) { ... }","handlingStrategy":"validation","validationCode":"// before build, per resource constructor parameter\nlong jaxrsParamCount = Stream.of(param.getAnnotations())\n        .map(Annotation::annotationType)\n        .map(Class::getName)\n        .filter(n -> n.equals(\"jakarta.ws.rs.QueryParam\") || n.equals(\"jakarta.ws.rs.PathParam\")\n                || n.equals(\"jakarta.ws.rs.MatrixParam\") || n.equals(\"jakarta.ws.rs.CookieParam\"))\n        .count();\nif (jaxrsParamCount > 1) throw new IllegalStateException(\"At most one JAX-RS param annotation allowed per constructor parameter\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give each constructor parameter exactly one JAX-RS parameter annotation","Review constructor signatures of resources with non-default constructors after refactoring","Prefer method-parameter injection for REST parameters","Keep a checkstyle/architectural rule forbidding stacked param annotations"],"tags":["jax-rs","resteasy-reactive","quarkus","deployment","constructor-injection"],"backgroundTag":"invalid-constructor-param-annotation","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"}