Micronaut controller error Page Not Found











up vote
0
down vote

favorite












I created a new micronaut app using
mn create-app example.micronaut.complete



After that I opened the project using intellij and added a new class as TestController to the project with code below:



package example.micronaut;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;


@Controller("/hello")
public class TestController {

TestController(){}

@Get(value = "/", produces = MediaType.TEXT_PLAIN)
String getTest(){
return "some string";
}
}


But I am getting



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


whenever I try to access the /hello end point



My application.yml looks like this:



micronaut:
application:
name: complete
server:
port: 8080









share|improve this question




























    up vote
    0
    down vote

    favorite












    I created a new micronaut app using
    mn create-app example.micronaut.complete



    After that I opened the project using intellij and added a new class as TestController to the project with code below:



    package example.micronaut;
    import io.micronaut.http.MediaType;
    import io.micronaut.http.annotation.Controller;
    import io.micronaut.http.annotation.Get;


    @Controller("/hello")
    public class TestController {

    TestController(){}

    @Get(value = "/", produces = MediaType.TEXT_PLAIN)
    String getTest(){
    return "some string";
    }
    }


    But I am getting



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


    whenever I try to access the /hello end point



    My application.yml looks like this:



    micronaut:
    application:
    name: complete
    server:
    port: 8080









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I created a new micronaut app using
      mn create-app example.micronaut.complete



      After that I opened the project using intellij and added a new class as TestController to the project with code below:



      package example.micronaut;
      import io.micronaut.http.MediaType;
      import io.micronaut.http.annotation.Controller;
      import io.micronaut.http.annotation.Get;


      @Controller("/hello")
      public class TestController {

      TestController(){}

      @Get(value = "/", produces = MediaType.TEXT_PLAIN)
      String getTest(){
      return "some string";
      }
      }


      But I am getting



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


      whenever I try to access the /hello end point



      My application.yml looks like this:



      micronaut:
      application:
      name: complete
      server:
      port: 8080









      share|improve this question















      I created a new micronaut app using
      mn create-app example.micronaut.complete



      After that I opened the project using intellij and added a new class as TestController to the project with code below:



      package example.micronaut;
      import io.micronaut.http.MediaType;
      import io.micronaut.http.annotation.Controller;
      import io.micronaut.http.annotation.Get;


      @Controller("/hello")
      public class TestController {

      TestController(){}

      @Get(value = "/", produces = MediaType.TEXT_PLAIN)
      String getTest(){
      return "some string";
      }
      }


      But I am getting



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


      whenever I try to access the /hello end point



      My application.yml looks like this:



      micronaut:
      application:
      name: complete
      server:
      port: 8080






      micronaut






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      saw303

      3,38212855




      3,38212855










      asked Nov 19 at 18:06









      Khwaja Sanjari

      837




      837
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...



          package example.micronaut;

          import io.micronaut.http.MediaType;
          import io.micronaut.http.annotation.Controller;
          import io.micronaut.http.annotation.Get;


          @Controller("/hello")
          public class TestController {

          // this empty constructor is not
          // needed, but isn't a problem...
          TestController() {
          }

          @Get(value = "/", produces = MediaType.TEXT_PLAIN)
          String getTest() {
          return "some string";
          }
          }


          The endpoint responds:



          $ curl http://localhost:8080/hello
          some string


          One thing to look for is you may be missing the micronaut-inject-java and/or micronaut-inject dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.



          Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.






          share|improve this answer





















          • It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
            – Jeff Scott Brown
            Nov 19 at 18:23










          • Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
            – Khwaja Sanjari
            Nov 19 at 19:09










          • "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
            – Jeff Scott Brown
            Nov 19 at 19:21






          • 1




            If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
            – Jeff Scott Brown
            Nov 19 at 19:24






          • 1




            If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
            – Jeff Scott Brown
            Nov 19 at 19:25













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380347%2fmicronaut-controller-error-page-not-found%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...



          package example.micronaut;

          import io.micronaut.http.MediaType;
          import io.micronaut.http.annotation.Controller;
          import io.micronaut.http.annotation.Get;


          @Controller("/hello")
          public class TestController {

          // this empty constructor is not
          // needed, but isn't a problem...
          TestController() {
          }

          @Get(value = "/", produces = MediaType.TEXT_PLAIN)
          String getTest() {
          return "some string";
          }
          }


          The endpoint responds:



          $ curl http://localhost:8080/hello
          some string


          One thing to look for is you may be missing the micronaut-inject-java and/or micronaut-inject dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.



          Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.






          share|improve this answer





















          • It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
            – Jeff Scott Brown
            Nov 19 at 18:23










          • Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
            – Khwaja Sanjari
            Nov 19 at 19:09










          • "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
            – Jeff Scott Brown
            Nov 19 at 19:21






          • 1




            If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
            – Jeff Scott Brown
            Nov 19 at 19:24






          • 1




            If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
            – Jeff Scott Brown
            Nov 19 at 19:25

















          up vote
          1
          down vote



          accepted










          Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...



          package example.micronaut;

          import io.micronaut.http.MediaType;
          import io.micronaut.http.annotation.Controller;
          import io.micronaut.http.annotation.Get;


          @Controller("/hello")
          public class TestController {

          // this empty constructor is not
          // needed, but isn't a problem...
          TestController() {
          }

          @Get(value = "/", produces = MediaType.TEXT_PLAIN)
          String getTest() {
          return "some string";
          }
          }


          The endpoint responds:



          $ curl http://localhost:8080/hello
          some string


          One thing to look for is you may be missing the micronaut-inject-java and/or micronaut-inject dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.



          Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.






          share|improve this answer





















          • It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
            – Jeff Scott Brown
            Nov 19 at 18:23










          • Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
            – Khwaja Sanjari
            Nov 19 at 19:09










          • "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
            – Jeff Scott Brown
            Nov 19 at 19:21






          • 1




            If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
            – Jeff Scott Brown
            Nov 19 at 19:24






          • 1




            If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
            – Jeff Scott Brown
            Nov 19 at 19:25















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...



          package example.micronaut;

          import io.micronaut.http.MediaType;
          import io.micronaut.http.annotation.Controller;
          import io.micronaut.http.annotation.Get;


          @Controller("/hello")
          public class TestController {

          // this empty constructor is not
          // needed, but isn't a problem...
          TestController() {
          }

          @Get(value = "/", produces = MediaType.TEXT_PLAIN)
          String getTest() {
          return "some string";
          }
          }


          The endpoint responds:



          $ curl http://localhost:8080/hello
          some string


          One thing to look for is you may be missing the micronaut-inject-java and/or micronaut-inject dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.



          Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.






          share|improve this answer












          Without seeing more of your project it is hard to say what is wrong. I have pasted your code directly into a project and it works as expected. See the project at https://github.com/jeffbrown/khwaja404. The controller at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/src/main/java/example/micronaut/TestController.java works fine...



          package example.micronaut;

          import io.micronaut.http.MediaType;
          import io.micronaut.http.annotation.Controller;
          import io.micronaut.http.annotation.Get;


          @Controller("/hello")
          public class TestController {

          // this empty constructor is not
          // needed, but isn't a problem...
          TestController() {
          }

          @Get(value = "/", produces = MediaType.TEXT_PLAIN)
          String getTest() {
          return "some string";
          }
          }


          The endpoint responds:



          $ curl http://localhost:8080/hello
          some string


          One thing to look for is you may be missing the micronaut-inject-java and/or micronaut-inject dependency as expressed at https://github.com/jeffbrown/khwaja404/blob/a3e57623ed5b30e28eb95bfe0f4a4a5c9d123fd8/build.gradle#L27-L29.



          Another is if you are running the app from the IDE (like IntelliJ IDEA), make sure you have annotation processors enabled in the build.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 18:19









          Jeff Scott Brown

          14.7k11731




          14.7k11731












          • It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
            – Jeff Scott Brown
            Nov 19 at 18:23










          • Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
            – Khwaja Sanjari
            Nov 19 at 19:09










          • "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
            – Jeff Scott Brown
            Nov 19 at 19:21






          • 1




            If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
            – Jeff Scott Brown
            Nov 19 at 19:24






          • 1




            If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
            – Jeff Scott Brown
            Nov 19 at 19:25




















          • It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
            – Jeff Scott Brown
            Nov 19 at 18:23










          • Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
            – Khwaja Sanjari
            Nov 19 at 19:09










          • "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
            – Jeff Scott Brown
            Nov 19 at 19:21






          • 1




            If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
            – Jeff Scott Brown
            Nov 19 at 19:24






          • 1




            If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
            – Jeff Scott Brown
            Nov 19 at 19:25


















          It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
          – Jeff Scott Brown
          Nov 19 at 18:23




          It is impossible to tell from your code sample if you are using Java or Groovy. The sample I linked is using Java. If you are using Groovy, of course you need the micronaut-inject-groovy dependency.
          – Jeff Scott Brown
          Nov 19 at 18:23












          Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
          – Khwaja Sanjari
          Nov 19 at 19:09




          Thanks for the quick response. My bad I keep on forgetting to enable annotation processor. Thanks for pointing it out. I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.
          – Khwaja Sanjari
          Nov 19 at 19:09












          "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
          – Jeff Scott Brown
          Nov 19 at 19:21




          "I would like to know if there is a way to enable console debug logging in IDE for micronaut similar to spring boot.". Yes you can. See github.com/jeffbrown/khwaja404/blob/master/src/main/resources/….
          – Jeff Scott Brown
          Nov 19 at 19:21




          1




          1




          If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
          – Jeff Scott Brown
          Nov 19 at 19:24




          If you don't know how to enable compile time annotation processors in Eclipse, you should post that as a separate question.
          – Jeff Scott Brown
          Nov 19 at 19:24




          1




          1




          If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
          – Jeff Scott Brown
          Nov 19 at 19:25






          If you checkout the project I linked and run ./gradlew run (or gradlew run if you are using the basic Windows shell), you will see that the Micronaut endpoint works fine.
          – Jeff Scott Brown
          Nov 19 at 19:25




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380347%2fmicronaut-controller-error-page-not-found%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'