Description
Serverless Java Container version: 2.0.0-M1
Implementations: Spring Boot 3
Framework version: SpringBoot 3.1.0
Frontend service: HTTP API
Deployment method: Console
Scenario
I've tried to deploy a simple GraphQL API using spring-boot-starter-graphql and aws-serverless-java-conainer-springboot3.
When I run it on a local environment using Tomcat, the request is processed normally. However, when I deploy it on AWS Lambda, I get an org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input error.
It seems error occurs while handling request.
I've been trying to solve it for three-full-days, but it hasn't been resolved. Any help would be appreciated.
Expected behavior
200 response should come when a request is sent to http api gateway url using curl.
curl 'https://[APIGATEWAY_URL]/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'Origin: altair://-' --data-binary '{"query":"query example{\n exampleQuery(input: { id: 1 }) {\n ok\n }\n}\n","variables":{}}' --compressed
Actual behavior
An error occurs as shown in the log below.
Steps to reproduce
This is the smallest project repository that can reproduce the error.
https://github.com/2012160085/photomanagement
Full log output
START RequestId: 5beefda9-8340-4539-a1b1-c1e154571024 Version: $LATEST
--
2023-05-31T07:18:56.999Z TRACE 8 --- [ main] o.s.b.w.s.f.OrderedRequestContextFilter : Bound request context to thread: com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest@450794b4
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.web.servlet.DispatcherServlet : POST "/graphql", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Method "[GET]" does not match against value "POST"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Method "[POST]" matches against value "POST"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Pattern "/graphql" matches against value "/graphql"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Content-Type "[application/json]" matches against value "application/json;charset=UTF-8"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Accept "[application/graphql-response+json, application/json, application/graphql+json]" matches against value "[application/json]"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.servlet.function.RouterFunctions : Predicate "((POST && /graphql) && (Content-Type: application/json && Accept: [application/graphql-response+json, application/json, application/graphql+json]))" matches against "HTTP POST /graphql"
2023-05-31T07:18:57.000Z TRACE 8 --- [ main] o.s.w.s.f.support.RouterFunctionMapping : Mapped to org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration$Lambda$909/0x0000000801c42aa0@332a7fce
2023-05-31T07:18:57.001Z DEBUG 8 --- [ main] o.s.g.server.webmvc.GraphQlHttpHandler : Executing: document='query example{
exampleQuery(input: { id: 1 }) {
ok
}
}
', operationName='example', id=a1e5941b-7608-2e7e-389f-de1c93d105df, Locale=ko
2023-05-31T07:18:57.003Z TRACE 8 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'exampleController'
2023-05-31T07:18:57.003Z TRACE 8 --- [ main] o.s.graphql.data.method.HandlerMethod : Arguments: [TestInput(id=1)]
2023-05-31T07:18:57.003Z DEBUG 8 --- [ main] o.s.g.server.webmvc.GraphQlHttpHandler : Execution complete
2023-05-31T07:18:57.004Z DEBUG 8 --- [ main] o.s.w.c.request.async.WebAsyncManager : Started async request
2023-05-31T07:18:57.004Z DEBUG 8 --- [ main] o.s.w.c.request.async.WebAsyncManager : Async result set, dispatch to /graphql
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.web.servlet.DispatcherServlet : "ASYNC" dispatch for POST "/graphql", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Method "[GET]" does not match against value "POST"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Method "[POST]" matches against value "POST"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Pattern "/graphql" matches against value "/graphql"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Content-Type "[application/json]" matches against value "application/json;charset=UTF-8"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.function.RequestPredicates : Accept "[application/graphql-response+json, application/json, application/graphql+json]" matches against value "[application/json]"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.servlet.function.RouterFunctions : Predicate "((POST && /graphql) && (Content-Type: application/json && Accept: [application/graphql-response+json, application/json, application/graphql+json]))" matches against "HTTP POST /graphql"
2023-05-31T07:18:57.004Z TRACE 8 --- [ main] o.s.w.s.f.support.RouterFunctionMapping : Mapped to org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration$Lambda$909/0x0000000801c42aa0@332a7fce
2023-05-31T07:18:57.005Z WARN 8 --- [ main] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input]
2023-05-31T07:18:57.005Z TRACE 8 --- [ main] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned.
2023-05-31T07:18:57.005Z DEBUG 8 --- [ main] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 400, headers={}
2023-05-31T07:18:57.005Z TRACE 8 --- [ main] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned.
2023-05-31T07:18:57.005Z DEBUG 8 --- [ main] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 400, headers={}
2023-05-31T07:18:57.005Z TRACE 8 --- [ main] o.s.b.w.s.f.OrderedRequestContextFilter : Cleared thread-bound request context: com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest@450794b4
2023-05-31T07:18:57.005Z INFO 8 --- [ main] c.a.s.p.internal.LambdaContainerHandler : 222.237.84.246 null- null [31/05/2023:07:18:56Z] "POST /graphql HTTP/1.1" 400 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) AltairGraphQLClient/5.0.20 Chrome/102.0.5005.167 Electron/19.0.10 Safari/537.36" combined
END RequestId: 5beefda9-8340-4539-a1b1-c1e154571024
REPORT RequestId: 5beefda9-8340-4539-a1b1-c1e154571024 Duration: 9.80 ms Billed Duration: 10 ms Memory Size: 1024 MB Max Memory Used: 192 MB
For comparision, local log with Tomcat.
2023-05-31T16:37:45.233+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.b.w.s.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@4890085a
2023-05-31T16:37:45.234+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : POST "/graphql", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Method "[GET]" does not match against value "POST"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Method "[POST]" matches against value "POST"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Pattern "/graphql" matches against value "/graphql"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Content-Type "[application/json]" matches against value "application/json;charset=UTF-8"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Accept "[application/graphql-response+json, application/graphql+json, application/json]" matches against value "[application/json]"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.servlet.function.RouterFunctions : Predicate "((POST && /graphql) && (Content-Type: application/json && Accept: [application/graphql-response+json, application/graphql+json, application/json]))" matches against "HTTP POST /graphql"
2023-05-31T16:37:45.235+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.f.support.RouterFunctionMapping : Mapped to org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration$$Lambda$1053/0x000000080145ab38@7c1a8f0f
2023-05-31T16:37:45.236+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.g.server.webmvc.GraphQlHttpHandler : Executing: document='query example{
exampleQuery(input: { id: 1 }) {
ok
}
}
', operationName='example', id=9681b2c4-bd16-f0fb-6997-6098e9a2736f, Locale=ko
2023-05-31T16:37:45.239+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'exampleController'
2023-05-31T16:37:45.240+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.graphql.data.method.HandlerMethod : Arguments: [TestInput(id=1)]
2023-05-31T16:37:45.240+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.g.server.webmvc.GraphQlHttpHandler : Execution complete
2023-05-31T16:37:45.241+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.w.c.request.async.WebAsyncManager : Started async request
2023-05-31T16:37:45.241+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.w.c.request.async.WebAsyncManager : Async result set, dispatch to /graphql
2023-05-31T16:37:45.241+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Exiting but response remains open for further handling
2023-05-31T16:37:45.241+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.b.w.s.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@4890085a
2023-05-31T16:37:45.241+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.b.w.s.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@4f70ef6c
2023-05-31T16:37:45.242+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : "ASYNC" dispatch for POST "/graphql", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2023-05-31T16:37:45.242+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Method "[GET]" does not match against value "POST"
2023-05-31T16:37:45.242+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Method "[POST]" matches against value "POST"
2023-05-31T16:37:45.242+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Pattern "/graphql" matches against value "/graphql"
2023-05-31T16:37:45.243+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Content-Type "[application/json]" matches against value "application/json;charset=UTF-8"
2023-05-31T16:37:45.243+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.function.RequestPredicates : Accept "[application/graphql-response+json, application/graphql+json, application/json]" matches against value "[application/json]"
2023-05-31T16:37:45.243+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.servlet.function.RouterFunctions : Predicate "((POST && /graphql) && (Content-Type: application/json && Accept: [application/graphql-response+json, application/graphql+json, application/json]))" matches against "HTTP POST /graphql"
2023-05-31T16:37:45.243+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.f.support.RouterFunctionMapping : Mapped to org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration$$Lambda$1053/0x000000080145ab38@7c1a8f0f
2023-05-31T16:37:45.243+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.w.s.f.s.HandlerFunctionAdapter : Resume with async result [org.springframework.web.servlet.function.DefaultEntityResponseBuilder$DefaultEntityResponse@67450a4c]
2023-05-31T16:37:45.244+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned.
2023-05-31T16:37:45.244+09:00 DEBUG 47111 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Exiting from "ASYNC" dispatch, status 200, headers={masked}
2023-05-31T16:37:45.244+09:00 TRACE 47111 --- [nio-8080-exec-8] o.s.b.w.s.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest@4f70ef6c