IntelliJ IDEA Config cant find AWS Lambda Handler in Default 'helloworld' Application
Asked Answered
E

1

10

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.

Ethiopic answered 8/4, 2019 at 15:35 Comment(2)
What did you change in PyCharm? I've tried marking/unmarking everything up the chain.Oxendine
@MikeMcCabe with the current up-to-date installations required for the pycharm counterpart (I'm using Windows 10 Pro) the default settings for the "hello_world" application work after pointing the AWS Lambda Configuration to the YAML file (along with the other settings such as login). My advice would be to make a new StackOverflow question with more detail and I will be happy to help.Ethiopic
F
15

On project files, right click on HelloWorldFunction then find Mark directory as and choose Source Root. That should fix your problems.

enter image description here

Fritzfritze answered 10/4, 2019 at 17:46 Comment(1)
I can confirm this answer fixes the issue.Ethiopic

© 2022 - 2024 — McMap. All rights reserved.