When setting the debug configurations for the default IntelliJ IDEA Java helloworld application (created upon making a new AWS Lambda project) the following response is shown:
Error: Cannot find handler 'helloworld.App::handleRequest' in project."
To fix this I've tried editing 'Handler' element inside template.yaml to include a filepath, though there had been no success.
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::handleRequest
I noticed the Python AWS Lambda helloworld project (within the PyCharm counterpart) required me to change the root project folder (allowing the handler to be found), however, I cant seem to achieve this with the Java counterpart within IntelliJ.
The default project file structure is as follows:
bash
├── README.mdH
├── HelloWorldFunction
│ ├── pom.xml
│ └── src
│ ├── main
│ │ └── java
│ │ └── helloworld
│ │ ├── App.java
│ │ └── GatewayResponse.java
│ └── test
│ └── java
│ └── helloworld
│ └── AppTest.java
└── template.yaml
The relevant section of the template.yaml file contains:
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::handleRequest
Runtime: java8
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
The App.java file contains the class
public class App implements RequestHandler<Object, Object> {
...
}
I would like the debug configuration to point to the correct Handler ( being "helloworld.App::handleRequest") so I can run the project on my local machine.
Refresh lists with AWS Lambda functions, JAR-artifacts, regions and profiles Select am AWS Lambda function in the list. Hit the button "Update Function". Type an input for test function of open it from json-file. Hit the Run button to run the test.
In IntelliJ IDEA, I'll click on the Save blue button. Then, in the AWS Explorer window, I'll click on the credentials drop-down menu. I can now see the Profile:default associated with my credentials. Once I select the default profile, IntelliJ IDEA will load a list of AWS services associated with my AWS account.
Then, with IntelliJ IDEA, PyCharm, WebStorm, or JetBrains Rider already running, do one of the following: Open AWS Explorer, if it isn't already open. If you need to switch to a different AWS Region to create the function in, do that now. Then right-click Lambda, and choose Create new AWS Lambda.
On project files, right click on HelloWorldFunction
then find Mark directory as
and choose Source Root
. That should fix your problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With