Skip to content

AWS SAM not using shade uber jar #1

@owenmather

Description

@owenmather

The 1.30.0 version of SAM with Java11 does not appear to use the shade uber jar with all libs packaged.

Inspecting the .aws-sam build folder after sam build shows just the base classes present.

ubuntu@ip-192-168-0-253:~/aws-lambda-jenkins-agents/.aws-sam/build/AgentGitBashNodeFunction$ ll
total 20
drwxr-xr-x 4 root root 4096 Sep  5 18:41 ./
drwxr-xr-x 4 root root 4096 Sep  5 18:41 ../
drwxr-xr-x 3 root root 4096 Sep  5 18:41 io/
drwxr-xr-x 2 root root 4096 Sep  5 18:41 lib/
-rw-r--r-- 1 root root  428 Sep  5 18:40 log4j2.xml

S3 bucket contains the same after sam deploy
This results in ClassNotFoundException when invoking the Lambda functions

Caused by: java.lang.ClassNotFoundException: hudson.remoting.jnlp.Main

My workaround was to manually zip and push the contents of the uber jar but maybe there is a way to fix this with pom changes?

aws lambda update-function-code --function-name my-function --zip-file fileb://my-function.zip
root@ip-192-168-0-253:/home/ubuntu/aws-lambda-jenkins-agents/.aws-sam/build/AgentGitBashFunction# sam --version
SAM CLI, version 1.30.0
root@ip-192-168-0-253:/home/ubuntu/aws-lambda-jenkins-agents/.aws-sam/build/AgentGitBashFunction# mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-1016-aws", arch: "amd64", family: "unix"`

Great project btw thank you for making this! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions