Error testing Resource Provider - java.lang.ClassNotFoundException: software.amazon.cloudformation.<projectName>.HandlerWrapper
I'm following this tutorial here [1], and creating a Resource Provider using the cfn CLI.
When I run "sam local invoke TestEntrypoint --event sam-tests/create.json" I get error below.
Invoking software.amazon.cloudformation.command.HandlerWrapper::testEntrypoint (java8)
Fetching lambci/lambda:java8 Docker container image...... Mounting /Users/shantgup/Documents/CloudFormation-Command-Project/target/aws-cloudformation-command-handler-1.0-SNAPSHOT.jar as /var/task:ro,delegated inside runtime container START RequestId: 4d2dbf5e-b8c6-159e-9687-8b59ce7d918a Version: $LATEST java.lang.ClassNotFoundException: software.amazon.cloudformation.command.HandlerWrapper at java.net.URLClassLoader.findClass(URLClassLoader.java:382) 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)
Exception in thread "main" java.lang.Error: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected status code from invocation/response: 299
at lambdainternal.AWSLambda.
Now the file does not exist in my "src/main/java/software/amazon/cloudformation/<project_name>/"
But I see 3 of them in /target/classes/software/amazon/cloudformation/<project_name>. There's HandlerWrapper.class, HandlerWrapper$1.class, HandlerWrapper$2.class, HandlerWrapper$3.class.
Also, my build steps have been as follows:
- cfn generate
- Build project in IntelliJ Idea
- sam local invoke TestEntrypoint --event sam-tests/create.json
Any help to troubleshoot / fix this would be greatly appreciated.
[1] - https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-walkthrough.html
@shantgup You can mounting the jar /Users/shantgup/Documents/CloudFormation-Command-Project/target/aws-cloudformation-command-handler-1.0-SNAPSHOT.jar. So I double check that your jar does have the files you need (not the src).
Hi jfuss@, thank you so much for your reply.
"aws-cloudformation-command-handler-1.0-SNAPSHOT.jar" is an empty folder. I'm new to this, how do I ensure that it's created properly?
@shantgup We don't own the cfn cli, so I don't know how they build or do the operations you are asking. The steps I would follow:
- Go back through the walk through and make sure you are correctly following it.
- If that doesn't work, cut an issue to https://github.com/aws-cloudformation/cloudformation-cli and explain what is happening.
I am going to close this for now. You are using a process outside of SAM CLI to build and that seems to be the issue (given the jar is not correct). Feel free to re-open if there is something additional needed from us after going through the above steps.
I understand, thank you Jacob.
I am seeing the exact thing. Updated here just for the record.
SNAPSHOT jar is an empty folder!
I was stuck on this for a while bro,
You’re in luck. Try this
‘’’
mvn -Dmaven.test.skip=true package
‘’’
Sent from my iPhone
On Mar 22, 2020, at 9:51 AM, thinksanky [email protected] wrote:
I am seeing the exact thing. Updated here just for the record.
SNAPSHOT jar is an empty folder!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-sam-cli/issues/1872#issuecomment-602219793, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOKUE2C37PZRMR22Z47UTMLRIYQUJANCNFSM4LOCT7LA.
Thanks shantgup@
You are right my tests are failing due to which Jar was not built. Skipping the test does build it, but I need to fix my test first before going there! Strangely, its not find the class when it is in the classpath!.
Same error here - following the tutorial - the HandlerWrapper class isn't generated when running: sam local invoke TestEntrypoint --event sam-tests/create.json