Skip to content

Cannot debug a trivial Micronaut Gradle project #942

Open
@raducrisan1

Description

@raducrisan1

I have created a simple gradle micronaut project and I've added a trivial controller:

@Controller("/health")
public class HealthCheck {
    
    @Get()
    public HttpResponse<String> index() {        
        return HttpResponse.ok("success");
    }  
}

From VS Code I start debugging the project (F5 shortcut, using default launch.json file). VS Code started the debug mode but if I try to hit this controller from curl I get

{"message":"Page Not Found","_links":{"self":{"href":"/health","templated":false}}}
This does not happen if i start the project with gradle run. The curl command returns success

Environment
  • Operating System: Ubuntu 20.04
  • JDK version: openjdk version "15.0.2" 2021-01-19
    OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.2+7, mixed mode, sharing)
  • Visual Studio Code version: 1.52.1
  • Java extension version: Java Extension Pack v0.12.1
  • Java Debugger extension version: v0.30.0
Steps To Reproduce
  1. Create a micronaut project: mn create-app test
  2. From VSCode, add a simple class, name it for instance HealthCheck.java with the following content:
  package test;
  
  import io.micronaut.http.HttpResponse;
  import io.micronaut.http.annotation.Controller;
  import io.micronaut.http.annotation.Get;
  
  @Controller("/health")
  public class HealthCheck {
      
      @Get()
      public HttpResponse<String> index() {        
          return HttpResponse.ok("success");
      }  
  } 
  1. run gradle run and use curl http://localhost:8080/health to validate it returns success
  2. stop the gradle run process and start debug from VSCode, in my case I only pressed pressed F5
  3. run again curl http://localhost:8080/health

The latest curl command returns:

Current Result

{"message":"Page Not Found","_links":{"self":{"href":"/health","templated":false}}}

Expected Result

success

Additional Information

I suspect there is an issue with handling the annotation processor. If I run the same thing from IntelliJ Idea, it works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions