{"record":{"id":"fb127de9f935881b","repo":"quarkusio/quarkus","slug":"interceptor-method-validation-message-dynamically","errorCode":null,"errorMessage":"interceptor method validation message (dynamically built: must have exactly one parameter of type jakarta.interceptor.InvocationContext / zero parameters / correct return type, per interception type and placement)","messagePattern":"interceptor method validation message \\(dynamically built: must have exactly one parameter of type jakarta\\.interceptor\\.InvocationContext / zero parameters / correct return type, per interception type and placement\\)","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java","lineNumber":394,"sourceCode":"                if (errors.contains(InterceptorMethodError.MUST_HAVE_PARAMETER)\n                        || errors.contains(InterceptorMethodError.MUST_NOT_HAVE_PARAMETER)) {\n                    msg.append(\" and must \");\n                }\n                msg.append(\"have a return type of \");\n                if (mayReturnVoid) {\n                    msg.append(\"void\");\n                }\n                if (mayReturnVoid && mayReturnObject) {\n                    msg.append(\" or \");\n                }\n                if (mayReturnObject) {\n                    msg.append(\"java.lang.Object\");\n                }\n            }\n\n            msg.append(\": \").append(method).append(\" declared in \").append(method.declaringClass().name());\n\n            throw new DefinitionException(msg.toString());\n        }\n    }\n\n}\n","sourceCodeStart":376,"sourceCodeEnd":399,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java#L376-L399","documentation":"ArC's validateSignature throws this DefinitionException when an interceptor method (annotated @AroundInvoke, @AroundConstruct, @PostConstruct or @PreDestroy) has an invalid signature for its interception type and placement. Depending on the type, the method must have exactly one parameter of type jakarta.interceptor.InvocationContext (around methods), zero parameters (lifecycle callbacks), and a permitted return type (Object, or void for lifecycle callbacks in target classes).","triggerScenarios":"@AroundInvoke/@AroundConstruct method with zero or multiple parameters, or a first parameter not of type InvocationContext; @PostConstruct/@PreDestroy method with any parameter; wrong return type for the interception type (e.g. @AroundInvoke returning void where Object is required).","commonSituations":"Hand-writing interceptor methods from memory with wrong signatures; using javax.interceptor.InvocationContext instead of jakarta.interceptor.InvocationContext after a Jakarta EE migration; typos like a generic parameter type; copying a target-class interceptor method into an interceptor class (or vice versa) where rules differ.","solutions":["Change the @AroundInvoke/@AroundConstruct method signature to take exactly one jakarta.interceptor.InvocationContext parameter and return Object (or the required type).","Change @PostConstruct/@PreDestroy callback methods to take zero parameters (and a permitted void return).","Verify you are importing jakarta.interceptor.InvocationContext, not the legacy javax one."],"exampleFix":"// before\n@AroundInvoke void intercept(String name) { }\n// after\n@AroundInvoke Object intercept(InvocationContext ctx) throws Exception { return ctx.proceed(); }","handlingStrategy":"validation","validationCode":"// Verify interceptor method signature before use\nstatic boolean isValidAroundInvoke(java.lang.reflect.Method m) {\n    if (!m.isAnnotationPresent(jakarta.interceptor.AroundInvoke.class)) return true;\n    return m.getParameterCount() == 1\n        && m.getParameterTypes()[0] == jakarta.interceptor.InvocationContext.class\n        && m.getReturnType() != void.class;\n}","typeGuard":"static boolean hasInvocationContextSignature(java.lang.reflect.Method m) {\n    return m.getParameterCount() == 1\n        && jakarta.interceptor.InvocationContext.class.isAssignableFrom(m.getParameterTypes()[0]);\n}","tryCatchPattern":null,"preventionTips":["Memorize the spec signatures: around methods take one InvocationContext and return Object; lifecycle callbacks take zero params","After Jakarta migration, ensure imports are jakarta.interceptor.*, never javax.interceptor.*","Let the IDE generate interceptor method stubs instead of typing them by hand"],"tags":["cdi","quarkus","arc","interceptor","signature"],"backgroundTag":"invalid-interceptor-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"}