I am attempting to use the aws lambda seed project received from here
The source code for the generated project is here
I imported the sbt dependencies and built the project using sbt assembly command.
I took the jar file built and uploaded it to lambda directly. For the handler defined for at MyHandler::handler
// handler io.github.yeghishe.MySimpleHander::handler
// input "foo"
object MySimpleHander extends App {
def handler(name: String, context: Context): String = s"Hello $name"
}
case class Name(val name: String)
case class Greeting(val message: String)
// handler io.github.yeghishe.MyHandler
// input {"name": "Yeghishe"}
class MyHandler extends Handler[Name, Greeting] {
def handler(name: Name, context: Context): Greeting = {
logger.info(s"Name is $name")
Greeting(s"Hello ${name.name}")
}
}
with the input event:
{
"name": "Yeghishe"
}
When I call the function, it shows the error:
{
"errorMessage": "An error occurred during JSON parsing",
"errorType": "java.lang.RuntimeException",
"stackTrace": [],
"cause": {
"errorMessage": "com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.lendi.hellolambda.Name]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@1dfe2924; line: 1, column: 2]",
"errorType": "java.io.UncheckedIOException",
"stackTrace": [],
"cause": {
"errorMessage": "No suitable constructor found for type [simple type, class com.lendi.hellolambda.Name]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@1dfe2924; line: 1, column: 2]",
"errorType": "com.fasterxml.jackson.databind.JsonMappingException",
"stackTrace": [
"com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)",
"com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1106)",
"com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:296)",
"com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)",
"com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1511)",
"com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1102)"
]
}
}
}