-
Notifications
You must be signed in to change notification settings - Fork 573
Description
- Framework version: 1.1
- Implementations: Spring Boot
Scenario
I'm trying to create a new serverless Spring Boot application using the provided Maven archetype and following the instructions here: https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot.
However, when I try running the newly created project locally through the aws-sam-cli sam local start-api -t sam.yaml command and then hit the /ping endpoint via http://127.0.0.1:3000/ping I get a ClassNotFoundException complaining about the StreamLambdaHandler class.
Some googling have checking the created .jar file to ensure it has all dependencies packaged with the requisite global read permissions as mentioned here https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html.
Running a zipinfo on the jar created by the shade plugin shows all the dependencies (including the StreamLambdaHandler class that it is complaining about) but it didn't have the required global read permissions:

Seeing that, I tried switching out the shade plugin with the maven-assembly-plugin in the pom.xml as follows:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
That creates a jar bundled with all the dependencies with the requisite global read permissions:

I then updated the sam.yaml file to point to the correct jar file and tried executing sam local start-api -t sam.yaml again but encountered the same ClassNotFoundException.
I have not changed any other file or configuration that the Maven archetype has set-up.
I am also encountering this same problem on a separate project that I have deployed to AWS Lambda via the aws cloudFormation commands.
Expected behavior
Newly created project using the provided Maven archetype should run OOTB without errors.
Actual behavior
Getting a ClassNotFoundException on the StreamLambdaHandler.
Steps to reproduce
- Create new serverless Spring Boot project via:
mvn archetype:generate -DgroupId=my.service -DartifactId=my-service -Dversion=1.0-SNAPSHOT \
-DarchetypeGroupId=com.amazonaws.serverless.archetypes \
-DarchetypeArtifactId=aws-serverless-springboot-archetype \
-DarchetypeVersion=1.1
-
Build project via:
mvn clean install(from root project directory) -
Run locally via:
sam local start-api -t sam.yaml(from root project directory) -
Attempt to hit
/pingendpoint in browser via:
http://127.0.0.1:3000/ping
