{"record":{"id":"b5dc4e14e3166b3a","repo":"quarkusio/quarkus","slug":"the-combination-of-annotationname-and-serv-b5dc4e","errorCode":null,"errorMessage":"The combination of '@${annotationName}' and '@ServerExceptionMapper' is not allowed. Offending method is '${methodName}' of class '${className}'","messagePattern":"The combination of '@(.+?)' and '@ServerExceptionMapper' is not allowed\\. Offending method is '(.+?)' of class '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java","lineNumber":509,"sourceCode":"                continue;\n            }\n            MethodInfo methodInfo = instance.target().asMethod();\n            if (methodInfo.isBridge()) { // we don't want to generate duplicates for bridge methods added by javac to handle generics\n                continue;\n            }\n            if (classLevelExceptionMappers.contains(methodInfo)) { // methods annotated with @ServerExceptionMapper that exist inside a Resource Class are handled differently\n                continue;\n            }\n            // the user class itself is made to be a bean as we want the user to be able to declare dependencies\n            additionalBeans.addBeanClass(methodInfo.declaringClass().name().toString());\n            Map<String, String> generatedClassNames = ServerExceptionMapperGenerator.generateGlobalMapper(methodInfo,\n                    new GeneratedBeanGizmoAdaptor(generatedBean),\n                    Set.of(HTTP_SERVER_REQUEST, HTTP_SERVER_RESPONSE, ROUTING_CONTEXT), Set.of(Unremovable.class.getName()),\n                    (m -> {\n                        List<AnnotationInstance> methodAnnotations = m.annotations();\n                        for (AnnotationInstance methodAnnotation : methodAnnotations) {\n                            if (CONDITIONAL_BEAN_ANNOTATIONS.contains(methodAnnotation.name())) {\n                                throw new RuntimeException(\n                                        \"The combination of '@\" + methodAnnotation.name().withoutPackagePrefix()\n                                                + \"' and '@ServerExceptionMapper' is not allowed. Offending method is '\"\n                                                + m.name() + \"' of class '\" + m.declaringClass().name() + \"'\");\n                            }\n                        }\n\n                        List<AnnotationInstance> classAnnotations = m.declaringClass().declaredAnnotations();\n                        for (AnnotationInstance classAnnotation : classAnnotations) {\n                            if (CONDITIONAL_BEAN_ANNOTATIONS.contains(classAnnotation.name())) {\n                                return true;\n                            }\n                        }\n                        return false;\n                    }));\n            for (Map.Entry<String, String> entry : generatedClassNames.entrySet()) {\n                ExceptionMapperBuildItem.Builder builder = new ExceptionMapperBuildItem.Builder(entry.getValue(),\n                        entry.getKey())\n                        .setRegisterAsBean(false) // it has already been made a bean","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveScanningProcessor.java#L491-L527","documentation":"Quarkus REST rejects combining bean-conditional annotations (@IfBuildProfile, @IfBuildProperty, etc.) with @ServerExceptionMapper. During deployment, exception mappers are generated into beans, and a method-level conditional annotation cannot be honored, so the build fails fast with the offending method and class named.","triggerScenarios":"Declaring a method annotated with @ServerExceptionMapper that also carries one of CONDITIONAL_BEAN_ANNOTATIONS (e.g. @IfBuildProfile, @IfBuildProperty) on the same method.","commonSituations":"Trying to activate an exception mapper only under a build profile or build property; copying a mapper from a CDI-based class while retaining its profile annotations.","solutions":["Remove the conditional annotation from the @ServerExceptionMapper method","Move the conditional annotation to the declaring class level","Use a plain CDI ExceptionMapper<...> bean with the conditional annotation instead","Duplicate the mapper across profiles using quarkus.* build-time properties via separate generated classes"],"exampleFix":"// before\n@IfBuildProperty(name = \"app.sec\", stringValue = \"on\")\n@ServerExceptionMapper\npublic Response map(SecurityException e) { ... }\n// after: class-level condition\n@IfBuildProperty(name = \"app.sec\", stringValue = \"on\")\npublic class SecMappers {\n    @ServerExceptionMapper\n    public Response map(SecurityException e) { ... }\n}\n","handlingStrategy":"validation","validationCode":"// build-time check: no conditional annotations on exception mapper methods\nfor (AnnotationInstance a : m.annotations()) {\n    if (CONDITIONAL_BEAN_ANNOTATIONS.contains(a.name())) {\n        throw new IllegalArgumentException(\"Remove \" + a + \" from @ServerExceptionMapper method \" + m.name());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep conditional annotations off @ServerExceptionMapper methods","Put conditions on the enclosing class instead","Use CDI ExceptionMapper beans when per-profile activation is needed"],"tags":["quarkus","resteasy-reactive","annotation-misuse","exception-mapper","build-time"],"backgroundTag":"incompatible-annotation-combination","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"}