{"record":{"id":"d777eef9bbcad4dc","repo":"quarkusio/quarkus","slug":"unable-to-find-handlerequest-method-in-handlercla","errorCode":null,"errorMessage":"Unable to find handleRequest method in <handlerClass.getName()>","messagePattern":"Unable to find handleRequest method in <handlerClass\\.getName\\(\\)>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/amazon-lambda/runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AmazonLambdaRecorder.java","lineNumber":67,"sourceCode":"\n    public void setStreamHandlerClass(Class<? extends RequestStreamHandler> handler) {\n        streamHandlerClass = handler;\n    }\n\n    static void initializeHandlerClass(RequestHandlerDefinition requestHandlerDefinition) {\n        handlerClass = requestHandlerDefinition.handlerClass();\n        ObjectMapper objectMapper = AmazonLambdaMapperRecorder.objectMapper;\n\n        if (requestHandlerDefinition.inputType().equals(S3Event.class)) {\n            objectReader = new S3EventInputReader(objectMapper);\n        } else if (Collection.class.isAssignableFrom(requestHandlerDefinition.inputType())) {\n            // we have to use reflection to figure out the element generic type\n            try {\n                Method handleRequestMethod = requestHandlerDefinition.handleRequestMethodHostClass().getMethod(\"handleRequest\",\n                        requestHandlerDefinition.inputType(), Context.class);\n                objectReader = new CollectionInputReader<>(objectMapper, handleRequestMethod.getGenericParameterTypes()[0]);\n            } catch (Exception e) {\n                throw new IllegalStateException(\"Unable to find handleRequest method in \" + handlerClass.getName(), e);\n            }\n        } else {\n            objectReader = new JacksonInputReader(objectMapper.readerFor(requestHandlerDefinition.inputType()));\n        }\n\n        Class<?> outputTypeForWriter = requestHandlerDefinition.outputType();\n        if (Record.class.equals(requestHandlerDefinition.outputType())) {\n            // Jackson won't properly serialize if the type is `Record`\n            outputTypeForWriter = Object.class;\n        }\n        objectWriter = new JacksonOutputWriter(objectMapper.writerFor(outputTypeForWriter));\n    }\n\n    public void setBeanContainer(BeanContainer container) {\n        beanContainer = container;\n    }\n\n    /**","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/amazon-lambda/runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AmazonLambdaRecorder.java#L49-L85","documentation":"AmazonLambdaRecorder.initializeHandlerClass uses reflection to locate the handleRequest(InputType, Context) method on the handler's host class for collection-input handlers. If that method signature cannot be found (or reflection otherwise fails), it throws IllegalStateException wrapping the cause, naming the handler class.","triggerScenarios":"Deploying a handler implementing a collection/generic RequestHandler whose host class lacks a handleRequest(InputType, Context) method matching the declared generic types — e.g. wrong generics, renamed/overloaded method, or native-image reflection issues.","commonSituations":"Generic RequestHandler<Input,Output> implementations where type erasure confuses the resolved host class; handlers implemented via intermediate abstract classes; signature mismatch after refactoring.","solutions":["Implement exactly handleRequest(InputType, Context) with the concrete input type in the class named as the handler","Ensure the handler class declares concrete generics (e.g. implements RequestHandler<MyIn, MyOut>), not raw types","Rebuild so the deployment and handler definitions agree on the input type","Check the wrapped cause for the exact reflection error (NoSuchMethodException etc.)"],"exampleFix":"// before\nclass MyHandler implements RequestHandler<Map<String, Object>, String> { // raw/erased usage\n    public String handleRequest(Object in, Context ctx) {...}\n}\n// after\nclass MyHandler implements RequestHandler<Map<String, Object>, String> {\n    public String handleRequest(Map<String, Object> in, Context ctx) {...}\n}","handlingStrategy":"validation","validationCode":"// build-time check: ensure the handler exposes the exact signature\nClass<?> h = MyHandler.class;\nMethod m;\ntry {\n    m = h.getMethod(\"handleRequest\", Map.class, Context.class);\n} catch (NoSuchMethodException e) {\n    throw new IllegalStateException(\"handler must declare handleRequest(InputType, Context)\", e);\n}","typeGuard":"static boolean hasHandleRequest(Class<?> c, Class<?> input) {\n    try { c.getMethod(\"handleRequest\", input, Context.class); return true; }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try { deploy(handler); } catch (IllegalStateException e) { throw new AssertionError(\"Bad handler signature: \" + e.getCause(), e); }","preventionTips":["Declare concrete generics on RequestHandler implementations","Keep handleRequest(InputType, Context) in the handler class itself","Add a unit test invoking handleRequest reflectively before packaging"],"tags":["reflection","amazon-lambda","handler-signature","native-image"],"backgroundTag":"method-not-found","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"}