Question: How do I resolve the "java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper" error in CloudFormation?

When I try to invoke my resource provider in AWS CloudFormation, I receive the following error:"java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper"Short descriptionYou receive the "java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper" error when you're developing or testing a resource provider schema file. You call cfn test or sam local invoke, but the /target/ directory in your project doesn't contain a valid .jar file.For other errors that are related to using a resource provider, see the following articles:How do I resolve the "Resource specification is invalid" error when I run the cfn generate command using the CloudFormation CLI in CloudFormation?How do I resolve the "Model validation failed (#: extraneous key [Key] is not permitted)" error in CloudFormation?How do I resolve the "Resource timed out waiting for creation of physical resource" error when I create a resource using my resource provider type in CloudFormation?How do I resolve the "Attribute 'Key' does not exist" error when I use the Fn::GetAtt function on my resource provider resource in CloudFormation?ResolutionBy default, the name of the .jar file is in the organization-service-resource-handler-1.0-SNAPSHOT.jar format and is configured in the pom.xml file in your project's root directory. For example:<groupId>com.organization.service.resource</groupId><artifactId>organization-service-resource-handler</artifactId><name>organization-service-resource-handler</name><version>1.0-SNAPSHOT</version><packaging>jar</packaging>To build your project, run cfn generate. Then, run mvn package. For example:$ cfn generateGenerated files for Organization::Service::Resource$ mvn package[INFO] Scanning for projects...[INFO] [INFO] --< software.organization.service.resource:organization-service-resource-handler >--[INFO] Building organization-service-resource-handler 1.0-SNAPSHOT[INFO] --------------------------------[ jar ]---------------------------------...[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time:  21.690 s[INFO] Finished at: 2020-07-14T16:02:47-05:00[INFO] ------------------------------------------------------------------------Note: If the build and tests are successful, then mvn creates the necessary**.jar** file in the /target/ directory.To skip the tests for unit tests that aren't complete, run mvn -Dmaven.test.skip=true package instead of mvn package.$ cfn generateGenerated files for Organization::Service::Resource$ mvn package -Dmaven.test.skip=true package[INFO] Scanning for projects...[INFO] [INFO] --< software.organization.service.resource:organization-service-resource-handler >--[INFO] Building organization-service-resource-handler 1.0-SNAPSHOT[INFO] --------------------------------[ jar ]---------------------------------...[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time:  21.690 s[INFO] Finished at: 2020-07-14T16:02:47-05:00[INFO] ------------------------------------------------------------------------Tip: You can troubleshoot the tests by navigating to the directory /target/surefire-reports from your project's root directory.

Related informationAWS CloudFormation CLI (from the GitHub website)