1

Hey so I downloaed all the tools for AWS toolkit required for eclipse, and new im trying to create A new AWS lambda project and I give it a package, project name and change input type to custom then provide String for input type and out Type, after loading it creates a project but comes back with errors so, please can some tell my what's wrong??

package com.amazonaws.lambda.demo;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class LambdaFunctionHandler implements RequestHandler<String, String> {

    @Override
    public String handleRequest(String input, Context context) // error is this hanleRequest it states Multiple markers at this line
    - The method handleRequest(String, Context) of type LambdaFunctionHandler must override a superclass method
    - implements   {
        context.getLogger().log("Input: " + input);

        // TODO: implement your handler
        return null;
    }

}


}
1
  • my lambda function will not run due to ..... { "errorMessage": "Unresolved compilation problem: \n\tThe method handleRequest(String, Context) of type LambdaFunctionHandler must override a superclass method\n", "errorType": "java.lang.Error", "stackTrace": [ "com.amazonaws.lambda.demo.LambdaFunctionHandler.handleRequest(LambdaFunctionHandler.java:9)", "com.amazonaws.lambda.demo.LambdaFunctionHandler.handleRequest(LambdaFunctionHandler.java:1)" ] } Commented Apr 7, 2017 at 16:22

1 Answer 1

1

The AWS documentation is outdated.

You need to implement a different interface.

Passing a map:

public class MyHandler implements RequestHandler<Map<String,Object>,String> 

Passing into a custom POJO object:

public class MyHandler implements RequestHandler<CustomRequest,CustomResponse> {

Consuming a stream:

public class MyHandler implements RequestStreamHandler {

Make sure to grab the right dependency:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-lambda-java-core</artifactId>
    <version>1.1.0</version>
</dependency>

I developed a sample application implementing each of the interfaces. You can just clone it from github. One of the handlers will print out all available environment variables as well.

Lambda expects JSON as input.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.