I am following a AWS Lambda tutorial. I have created a Lambda function that takes a custom class as input and outputs another custom class. On entering the test data I am getting a JSON parse error.
public class HelloPojo implements RequestHandler<RequestClass, ResponseClass>{
@Override
public ResponseClass handleRequest(RequestClass request, Context context){
String greetingString = String.format("Hello %s, %s.", request.firstName, request.lastName);
return new ResponseClass(greetingString);
}
}
This is the test input { "firstName":"John", "lastName":"Doe" }. I believe AWS requires input in json format and then it parses it. The following is the custom requestclass object:
public class RequestClass {
String firstName;
String lastName;
public RequestClass(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public RequestClass() {
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
This is the error message:
"errorMessage": "An error occurred during JSON parsing",
"errorType": "java.lang.RuntimeException",
"stackTrace": [],
"cause": {
"errorMessage": "org/json/simple/JSONObject",
"errorType": "java.lang.NoClassDefFoundError",
Here is the responseClass:
public class ResponseClass {
String greetings;
public ResponseClass(String greetings) {
this.greetings = greetings;
}
public ResponseClass() {
}
public String getGreetings() {
return greetings;
}
public void setGreetings(String greetings) {
this.greetings = greetings;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}