{"record":{"id":"d76b534e6ee86a6b","repo":"quarkusio/quarkus","slug":"method-info-name-of-class-info-declaringc-d76b53","errorCode":null,"errorMessage":"Method '${info.name()} of class '${info.declaringClass().name()}' cannot be static as it is annotated with '@jakarta.ws.rs.ext.Provider'","messagePattern":"Method '(.+?) of class '(.+?)' cannot be static as it is annotated with '@jakarta\\.ws\\.rs\\.ext\\.Provider'","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/exceptionmappers/ServerExceptionMapperGenerator.java","lineNumber":645,"sourceCode":"                    return ReturnType.UNI_RESPONSE;\n                }\n                if (parameterizedType.arguments().get(0).name().equals(REST_RESPONSE)) {\n                    return ReturnType.UNI_REST_RESPONSE;\n                }\n            }\n        }\n        throw new RuntimeException(\"Method '\" + targetMethod.name() + \" of class '\" + targetMethod.declaringClass().name()\n                + \"' cannot be used as an exception mapper as it does not declare 'Response' or 'Uni<Response>' or as its return type\");\n    }\n\n    private static void checkModifiers(MethodInfo info) {\n        if ((info.flags() & Modifier.PRIVATE) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be private as it is annotated with '@\" + SERVER_EXCEPTION_MAPPER\n                    + \"'\");\n        }\n        if ((info.flags() & Modifier.STATIC) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be static as it is annotated with '@\" + SERVER_EXCEPTION_MAPPER\n                    + \"'\");\n        }\n    }\n\n    private static String getGeneratedClassName(MethodInfo targetMethod, Type handledExceptionType) {\n        return targetMethod.declaringClass().name() + \"$ExceptionMapper$\"\n                + HashUtil.sha1(targetMethod.name() + handledExceptionType.name().toString());\n    }\n\n    private enum ReturnType {\n        RESPONSE,\n        REST_RESPONSE,\n        UNI_RESPONSE,\n        UNI_REST_RESPONSE\n    }\n\n    private static class TargetMethodParamsInfo {","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/exceptionmappers/ServerExceptionMapperGenerator.java#L627-L663","documentation":"checkModifiers in ServerExceptionMapperGenerator rejects static methods annotated as exception mappers. Generated server code invokes mapper methods on a bean instance, so static methods cannot be wired; a RuntimeException fails the build.","triggerScenarios":"Declaring a @ServerExceptionMapper or @Provider-annotated mapper method with the static modifier, detected during build-time generation.","commonSituations":"Writing stateless mappers as static 'utility' methods, converting helper methods to static after adding the annotation, or copying Java style from non-CDI code.","solutions":["Remove the static modifier from the mapper method","If truly stateless, keep it as a public instance method (CDI can instantiate it)","Remove the mapper annotation if the static method is not a mapper"],"exampleFix":"// before\n@ServerExceptionMapper\npublic static Response map(IllegalArgumentException e) { ... }\n\n// after\n@ServerExceptionMapper\npublic Response map(IllegalArgumentException e) { ... }","handlingStrategy":"validation","validationCode":"java.lang.reflect.Method m = ...; // annotated mapper\nif (java.lang.reflect.Modifier.isStatic(m.getModifiers())) {\n    throw new IllegalStateException(\"@ServerExceptionMapper methods must not be static: \" + m);\n}\n","typeGuard":"static boolean isInstanceMapper(java.lang.reflect.Method m) {\n    return !java.lang.reflect.Modifier.isStatic(m.getModifiers());\n}\n","tryCatchPattern":null,"preventionTips":["Never mark @ServerExceptionMapper methods static","Treat mapper methods as CDI bean members requiring an instance","Add a unit test that reflects over annotated mapper methods and asserts non-static, non-private"],"tags":["quarkus","resteasy-reactive","static-method","exception-mapper"],"backgroundTag":"invalid-exception-mapper-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"}