Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I have written following Hello World Lambda which I am executing by uploading on AWS via AWS toolkit for Eclipse.

public class HelloWorldLambdaHandler implements RequestHandler<String, String> {

    public String handleRequest(String input, Context context) {

        System.out.println("Hello World! executed with input: " + input);

        return input;



I am getting the following error when executing the above code. Any idea what I may be doing wrong here? BTW Maven project which has this handler doesn't have any other class and the only dependency is aws-lambda-java-core version 1.1.0.

Skip uploading function code since no local change is found...

Invoking function...

==================== FUNCTION OUTPUT ====================

{"errorMessage":"An error occurred during JSON parsing","errorType":"java.lang.RuntimeException","stackTrace":[],"cause":{"errorMessage":"com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: [email protected]; line: 1, column: 1]","errorType":"","stackTrace":[],"cause":{"errorMessage":"Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: [email protected]; line: 1, column: 1]","errorType":"com.fasterxml.jackson.databind.JsonMappingException","stackTrace":["com.fasterxml.jackson.databind.JsonMappingException.from(","com.fasterxml.jackson.databind.DeserializationContext.mappingException(","com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(","com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(","com.fasterxml.jackson.databind.ObjectReader._bindAndClose(","com.fasterxml.jackson.databind.ObjectReader.readValue("]}}}



1 Answer

0 votes
by (44.4k points)
selected by
Best answer

Amazon cannot deserialize JSON to string. It is not compatible. So, for handling JSON you can use Map or a custom POJO. 

public class HelloWorldLambdaHandler {

    public String handleRequest(Map<String,Object> input, Context context) {


        return "Hello";



Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories