You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version: 2.0.1
Implementations:Spring Boot
Framework version:SpringBoot 3.2.4
Frontend service:REST API
Deployment method:Serverless Framework
Scenario
Describe what you are trying to accomplish
Hello I am creating a lambda function for my service. when I try to call my post API with the json body from lambda test console it is not able to deserialize it into the object which is defined in my code
Expected behavior
Describe how you would expect the application to behave
When I pass the body as json input it should get deserialized and consumed in my spring boot application
Actual behavior
Describe what you are seeing instead
It is throwing java.lang.String from Object value
Steps to reproduce
*Provide code samples we can use to reproduce the issue as part of our integration tests. If there is a public repository for the misbehaving application link to it here
Paste the full log output from the Lambda function's CloudWatch logs
Below is the stack trace
2024-04-20T09:41:05.847+05:30 at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:197) ~[aws-lambda-java-runtime-interface-client-2.4.2-linux-x86_64.jar:2.4.2]
2024-04-20T09:41:05.847+05:30
at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:187) ~[aws-lambda-java-runtime-interface-client-2.4.2-linux-x86_64.jar:2.4.2]
at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:187) ~[aws-lambda-java-runtime-interface-client-2.4.2-linux-x86_64.jar:2.4.2]
2024-04-20T09:41:05.848+05:30
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)
2024-04-20T09:41:05.848+05:30 at [Source: (ByteArrayInputStream); line: 1, column: 59] (through reference chain: com.amazonaws.serverless.proxy.model.AwsProxyRequest["body"])
2024-04-20T09:41:05.848+05:30
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1752)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1526)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1431)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.DeserializationContext.extractScalarFromObject(DeserializationContext.java:943)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseString(StdDeserializer.java:1424)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:48)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.module.afterburner.deser.SettableStringMethodProperty.deserializeAndSet(SettableStringMethodProperty.java:41)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:278)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
2024-04-20T09:41:05.848+05:30 at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105)
2024-04-20T09:41:05.849+05:30 at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1481)
2024-04-20T09:41:05.849+05:30 at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:257)
2024-04-20T09:41:05.849+05:30 at com.<Removed>.StreamLambdaHandler.handleRequest(StreamLambdaHandler.java:36)
The text was updated successfully, but these errors were encountered:
Hey @Prajwalgn-07,
I have tried to reproduce your issue and figure out the cause. In this case I think the issue is with your JSON file, and you were almost on the right path. You need to keep your body value to String instead of json. And you have to set content-type in multiValueHeaders instead of headers, something like mentioned below will work.
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version:
2.0.1
Implementations:
Spring Boot
Framework version:
SpringBoot 3.2.4
Frontend service:
REST API
Deployment method:
Serverless Framework
Scenario
Describe what you are trying to accomplish
Hello I am creating a lambda function for my service. when I try to call my post API with the json body from lambda test console it is not able to deserialize it into the object which is defined in my code
Expected behavior
Describe how you would expect the application to behave
When I pass the body as json input it should get deserialized and consumed in my spring boot application
Actual behavior
Describe what you are seeing instead
It is throwing
java.lang.String
from Object valueSteps to reproduce
*Provide code samples we can use to reproduce the issue as part of our integration tests. If there is a public repository for the misbehaving application link to it here
Below is the test input given
StreamLambdaHandler
Rest Mapping
Full log output
Paste the full log output from the Lambda function's CloudWatch logs
Below is the stack trace
The text was updated successfully, but these errors were encountered: