Skip to content

Make the function-sample-aws simple to run on linux/macosx with updates instructions #1208

@roskelleycj

Description

@roskelleycj

Describe the issue

When following these instructions they lead to function-sample-aws and if you check that out and run it you can run into a set of problems that are difficult to understand/explain if you are new to the concepts of this project and not on windows.

It should be pretty easy to address by documenting the steps that are needed specific to the context. E.g., linux or macosx

Sample

These instructions suggest You simply execute ./mvnw clean package to generate JAR file. and since on my host (macosx) I don't use windows I translated to this You simply execute mvn clean package to generate JAR file. Pretty straightforward. However, the next steps deviate as I didn't want to run a deploy to AWS but rather switch to use AWS SAM locally FIRST, to get the hang of things.

And when I ran sam local invoke I get this:

Class not found: org.springframework.cloud.function.adapter.aws.FunctionInvoker: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: org.springframework.cloud.function.adapter.aws.FunctionInvoker
	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)

Which appears to be a very common problem that people ask about, however, there is no straightforward answer. There are however lots of finger pointing to AWS SAM or Spring Cloud Function etc. having the issues. In the end I was able to determine that there is indeed some expectations on AWS SAM about how the packaging of the code will be created when AWS SAM local is executed. It depends on sam build to be executed so that the artifacts will be located correctly in the container. However, when I ran sam build it chokes on the fact that I have no mvnw environment. Again, I assumed the instructions of mvn clean package were sufficient and so I missed that sam build was the only real means to get sam happy.

Specifically, I had to drop the mvnw et. al. (I literally deleted it). I also deleted the .aws-sam directory as I wanted to make sure I was clean on all accounts. Then I ran the sam build and then sam local invoke and everything worked as expected.

In other words lots of wasted time trying to get the simple 'demo' to work locally with Spring Cloud Function and AWS SAM local. And in a few post I found people just switched languages to python. 🤷

It would be ideal to document how to bootstrap for linux/macosx such that it just works on the first 10m instead of wasting time chasing ClassNotFoundException to get it to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions