Describe the bug
When following the guide:
mvn clean installsam local start-api --template sam.jvm.yamlhttp://127.0.0.1:3000/helloFetching lambci/lambda:java8 Docker container image......
Mounting /private/var/folders/2x/mp3q5n8d2136yqf5bl2r571m0000gn/T/tmpt84krkw6 as /var/task:ro,delegated inside runtime container
START RequestId: 2d7e86bb-fd7b-1012-35e5-a150c771aa47 Version: $LATEST
java.lang.ClassNotFoundException: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Expected behavior
Should return the result of the get request to the browser (as shown in the guide)
Actual behavior
browser returns error message:
{"message":"Internal server error"}
To Reproduce
Steps to reproduce the behavior:
http://127.0.0.1:3000/helloConfiguration
# Add your application.properties here, if applicable.
Screenshots
(If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
uname -a or ver: java -version: Additional context
Java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
cc @evanchooly @patriot1burke
this looks like an issue with SAM use of DockerMachine permission on sharing/copying files to the container for execution/mounting.
I reproduced it with the SAM HelloWorld app.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html
You can see it mentioned here:
https://github.com/awslabs/aws-sam-cli/issues/1092
Temporary workaround:
https://github.com/awslabs/aws-sam-cli/issues/1254
Or perhaps test this on docker-desktop instead of docker-toolbox (I have no choice because I'm on OSX El Capitan)
I'll see if I can reproduce. I didn't have a problem on my setup on Fedora. Should we just link this in docs?
Reproduced on Windows with stock archetype generated project, found this issue as result.
I have been following "QUARKUS - AMAZON LAMBDA" guide and I got the same error for the native package. I repeated all steps but manually creating the lambda in the AWS console. and I had exactly the same issue when running the code on AWS:
Class not found: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler
at java.base/java.net.URLClassLoader.findClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
When I uploaded non-native code (JAR) the lambda worked just fine.
{
"result": "hello Bill",
"requestId": "17a1f308-00db-427e-bf1f-5ae38e5a063e"
}
START RequestId: 17a1f308-00db-427e-bf1f-5ae38e5a063e Version: $LATEST
END RequestId: 17a1f308-00db-427e-bf1f-5ae38e5a063e
REPORT RequestId: 17a1f308-00db-427e-bf1f-5ae38e5a063e Duration: 1.37 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 124 MB
My development machine is macOS (Catalina).
java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07)
OpenJDK 64-Bit Server VM GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07, mixed mode, sharing)
mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
As per the pervious link I believe this is a sam docker issue wrt storage where the class path ends up being broken due to failed mounting or scp. awslabs/aws-sam-cli#1092
I have been at a conference this week but I will try to take a look when I'm back in the office next week.
I was experiencing this issue for the JVM version (native worked fine!), and I have now updated to the latest version of SAM 0.43, and the problem is resolved - JVM version working and no class not found exception.
Quarkus 1.2.1 Final - the native lambda worked - both: Java 8 and Java 11 native build.
I don't use local SAM, I only have GraalVM and I created Lambda manually, uploaded function.zip and it worked.
I should add, I presume 'native' will work due to a being a different runtime classloader mechanism. It was only on sam-local and seems like an issue with docker-toolkit and not docker desktop.
Oops seems the answer on my side was as simple as by default Amazon Lambda only builds a thin jar, which is why it works for native image as it brings in all classes used.
The following property needs to be added (when using maven):
quarkus.package.uber-jar=true
It would be nice if the Amazon Lambda extension by default forced this.
I have the same problem like @kolorobot
Working fine for me now on 1.4.2
SAM CLI, version 0.52.0
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-05-30 07:18:08,713 INFO [io.quarkus] (main) lambda-http 1.0-SNAPSHOT (powered by Quarkus 1.4.2.Final) started in 7.446s.
2020-05-30 07:18:08,721 INFO [io.quarkus] (main) Profile prod activated.
2020-05-30 07:18:08,722 INFO [io.quarkus] (main) Installed features: [amazon-lambda, cdi, mutiny, resteasy, servlet, vertx, vertx-web]
START RequestId: 11d37409-4027-1ce4-3a0b-ba22d8ddef31 Version: $LATEST
END RequestId: 11d37409-4027-1ce4-3a0b-ba22d8ddef31
REPORT RequestId: 11d37409-4027-1ce4-3a0b-ba22d8ddef31 Init Duration: 7790.11 ms Duration: 1224.32 ms Billed Duration: 1300 ms Memory Size: 512 MB Max Memory Used: 99 MB
2020-05-30 15:18:11 127.0.0.1 - - [30/May/2020 15:18:11] "GET /favicon.ico HTTP/1.1" 404 -