- Newest
- Most votes
- Most comments
The issue you're experiencing is related to how Lambda loads Java classes from deployment packages. When you use a .zip file as your deployment package, Lambda expects a specific structure for Java applications.
When you provide just the JAR file directly (target/amazon-0.0.1-SNAPSHOT.jar), Lambda can find your handler class because it knows how to load classes from a JAR file. However, when you package your JAR inside a .zip file, Lambda doesn't automatically know to look inside the JAR for your handler class.
For Java Lambda functions deployed with a .zip file, you need to follow a specific structure:
- Your compiled Java classes should be at the root of the .zip file, or
- Your JAR files should be in a
/libdirectory within the .zip file
To fix your issue, you have two options:
Option 1: Extract the contents of your JAR file and place them at the root of your .zip file along with your mediainfo binary.
Option 2: Create a .zip file with the following structure:
/lib/amazon-0.0.1-SNAPSHOT.jar (your JAR file goes here)
/mediainfo (your binary file)
Lambda will automatically load classes from JAR files in the /lib directory. This way, you can include both your Java code and the mediainfo binary in the same deployment package.
Make sure the files have the correct permissions (644 for non-executable files and 755 for directories and executable files) before creating the .zip file.
Sources
Deploy Java Lambda functions with .zip or JAR file archives - AWS Lambda
unable to upload zip folder from s3 to aws lambda | AWS re:Post
Unable to open file(s) uploaded as a zip file of a lambda function | AWS re:Post
answered a year ago
Relevant content
asked 3 years ago
asked 2 years ago
- AWS OFFICIALUpdated 4 years ago
