question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running SAM Local with Java on Windows

See original GitHub issue

I am trying to run the Java sample project on sam local under Windows. I have added CodeUri property to the template YAML to make the JAR file visible for SAM.

CodeUri: target/HelloWorld-1.0.jar

Docker Toolbox is installed and invoking a particular function fetches lambda docker image.

2017/10/27 08:42:08 Successfully parsed template.yml ←[34mINFO←[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/10/27 08:42:08 Connected to Docker 1.33 ←[34mINFO←[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/10/27 08:42:08 Fetching lambci/lambda:java8 image for java8 runtime… java8: Pulling from lambci/lambda Digest: sha256:5e1f24ebf98bf010e94e8eb7d3eeec3d24d2a7d97a458756dda27134de526aa2 Status: Image is up to date for lambci/lambda:java8

However invoking the function itself causes error:

2017/10/27 08:39:18 Reading invoke payload from stdin (you can also pass it from file with --event) 2017/10/27 08:39:18 Invoking com.aws.codestar.projecttemplates.handler.HelloWorldHandler (java8) 2017/10/27 08:39:18 Decompressing C:\Users\dzielins\git\P18-Bool\target\HelloWorld-1.0.jar 2017/10/27 08:39:18 Could not invoke function: Error response from daemon: invalid volume specification: ‘C:\Users\dzielins\AppData\Local\Temp\aws-sam-local-1509086358382936700:/var/task:ro’

As I have read in some other posts and README file, this might be caused by incorrect setting of Docker volume basedir. So I tried using both --docker-volume-basedir switch and environment variable SAM_DOCKER_VOLUME_BASEDIR by setting them to /c/Users/dzielins/git/P18-Bool as advised. This did not help in any way, as now the error that occurs is:

2017/10/27 08:41:01 Reading invoke payload from stdin (you can also pass it from file with --event) 2017/10/27 08:41:01 Invoking com.aws.codestar.projecttemplates.handler.HelloWorldHandler (java8) ←[32mSTART RequestId: 1d73caa9-7554-485d-8eaf-81de3a712d3a Version: $LATEST←[0m ←[31mjava.lang.ClassNotFoundException: com.aws.codestar.projecttemplates.handler.HelloWorldHandler at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348)

What should be done in order to make SAM Local and Docker instance see and invoke the built JAR file in correct way?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
PaulMaddoxcommented, Oct 31, 2017

Fix incoming soon!

0reactions
gruaucommented, Dec 1, 2017

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debug Serverless Applications Using AWS SAM Local
In the Eclipse Project Explorer, open HelloWorldHandler.java . Right-click in your Eclipse code window, choose Debug As, and then choose AWS SAM Local....
Read more >
AWS SAM, SAM Local, Java Serverless Application | by VJ Mali
SAM Setup & First JAVA Serverless App : 1. Install SAM CLI from AWS SAM Official docs · 6. Build the app :...
Read more >
AWS Lambda Function + SAM Local + IntelliJ IDEA + Java
Creating a AWS Lambda Function with SAM and IntelliJ IDEA. This video will provide yo step by step tutorial, using VS Code to...
Read more >
Running SAM Local with Java on Windows · Issue #183 - GitHub
I am trying to run the Java sample project on sam local under Windows. I have added CodeUri property to the template YAML...
Read more >
AWS SAM local with JAVA and Docker Toolbox - Stack Overflow
SAM Local leverages the docker-lambda Docker images to run your code in a sandbox that simulates the Lambda execution environment. I pulled the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found