Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
roskelleycj opened this issue Nov 24, 2024 · 1 comment
Milestone

Comments

@roskelleycj
Copy link

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.

@olegz
Copy link
Contributor

olegz commented Dec 10, 2024

@roskelleycj
First, thank you for all of these details. . . . and it seems like you have spent "some time" getting it to work.
Obviously there are (as you pointed out) certain expectations for SAM that could be different then for a real deployment. . .
But I do agree it would be nice if this could be documented.
Do you mind providing a documentation PR? I can guide you thru it as well.

@olegz olegz added this to the 4.2.1 milestone Dec 17, 2024
@olegz olegz closed this as completed in 637948a Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants