How do I run a zipped java file, created for lambda, locally?
When a zip is created by following the link
https://docs.aws.amazon.com/lambda/latest/dg/java-package.html
We can upload the zip to lambda for running application on it.
How do I run the zip if I need to test the functions locally.
By unzipping the same zipped file, I can see java classes compiled into *.class files.
When I ran java MainClass
it is throwing
Error: Unable to initialize main class MainClass
Caused by: java.lang.NoClassDefFoundError: org/redisson/client/codec/Codec
I am using redisson as a dependency here.
Note: I can create fatJar or other methods to test the function locally but I need to re use how lambda would run this zip.
I don’t want to run the lambda function locally.
I want to run the actual code, using the same zip created from gradle zip task.
Question can be worded as "How do I run java application from zip. The zip is created from a gradle task"
I am using gradle to build and make zip file
2
Answers
After zipping the java application with https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Zip.html.
All we need is to unzip the zipped file and pass in location of jars as class path.
The only way to debug/test AWS lambdas locally is by using AWS SAM in debug mode
You can’t just run the jar file. Have a look at the aws sam documentation. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html