I'm trying to write a simple java lambda function. However I keep receiving this error when I run the lambda test after uploading the jar file for the lambda function:
{
"errorMessage": "Class not found: org.example.HelloWorld.handler",
"errorType": "java.lang.ClassNotFoundException"
}
Here is the Java code for the lambda:
package org.example;
/**
* Hello world!
*
*/
public class HelloWorld
{
public String handler() {
return "Hello World";
}
}
For some more context this is a maven project, and I'm creating the jar file by running mvn clean package
from the root LambdaExample
directory.
Here is my file/directory structure for the project including the hello-lambda.jar
that gets uploaded to AWS lambda .
Here is my lambda function handler:
Here is the lambda function summary:
And here is full error output from AWS Lambda Test:
This seems like a pretty basic project and I followed a tutorial (this one) so it should work. Anyone know why I'm getting this error and how I can fix it?
CodePudding user response:
You had a typo while specifying the handler in the runtime settings. The correct way to specify the handler is:
packageName.className::method
In your case, instead of:
org.example.HelloWorld.handler
Change to:
org.example.HelloWorld::handler