quarkus: Quarkus 2.10.0 doesn't work for Simulate Amazon Lambda Deployment with SAM CLI

Describe the bug

With a simple app (e.g. Hello world REST API), Quarkus 2.9.2 allows me to simulate an AWS Lambda app using SAM CLI locally as below:

sam local start-api --template target/sam.jvm.yaml

But Quarkus 2.10.0 doesn’t work with the error as the actual behavior. I know that Quarkus dev mode is good enough to test the function since Quarkus dev mode starts a mock AWS Lambda event server that will convert HTTP requests. But as long as we provide the sam CLI guide in our doc(https://quarkus.io/guides/amazon-lambda-http), sam local test should work too.

Expected behavior

Start a Quarkus dev mode without an error then a developer can access the REST API to invoke the function.

Actual behavior

I have the following error:

2022-06-27 17:18:36,102 ERROR [qua.ama.lam.http] (main) Request Failure: java.lang.ClassCastException: class lambdainternal.api.LambdaContext cannot be cast to class io.quarkus.amazon.lambda.runtime.AmazonLambdaContext (lambdainternal.api.LambdaContext is in unnamed module of loader 'app'; io.quarkus.amazon.lambda.runtime.AmazonLambdaContext is in unnamed module of loader lambdainternal.CustomerClassLoader @1a6c5a9e)
	at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:70)
	at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:47)
	at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.handle(AmazonLambdaRecorder.java:85)
	at io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler.handleRequest(QuarkusStreamHandler.java:58)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375)
	at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899)
	at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:268)
	at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:206)
	at lambdainternal.AWSLambda.main(AWSLambda.java:200)

END RequestId: 11f8a8d0-2db1-48b2-a39d-5e15caea30c9
REPORT RequestId: 11f8a8d0-2db1-48b2-a39d-5e15caea30c9	Init Duration: 0.16 ms	Duration: 3012.45 ms	Billed Duration: 3013 ms	Memory Size: 512 MB	Max Memory Used: 512 MB	
No Content-Type given. Defaulting to 'application/json'.
2022-06-27 13:18:36 127.0.0.1 - - [27/Jun/2022 13:18:36] "GET /hello/greeting/awslocal HTTP/1.1" 500 -

How to Reproduce?

No response

Output of uname -a or ver

Darwin Daniels-MacBook-Pro 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

Output of java -version

openjdk version “11.0.10” 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.10.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@danieloh30 Very nice bug report. Have more or less the same issue deploying with CDK.

Downgraded to 2.9.2.Final and it works.

@gsmet Looking forward to the next 2.10 next Wednesday