Spring returning HTTP 404 even though URL is mapped












0















When i access the url http://localhost:8080/test/testSpring, my spring boot app returned 404 error even though I have mapped the URL in my controller.



My REST service:



@RestController
public class TestSpring {
@RequestMapping(value="/test/testSpring", method=RequestMethod.GET)
public String test() {
return "test ok";
}
}


Console log shows URL is mapped:



RequestHandlerMapping - Mapped "{[/test/testSpring],methods=[GET]}" onto public java.lang.String ...









share|improve this question

























  • do you have context path property in application.properties? also attach screenshot of directory structure of project.

    – Alien
    Nov 21 '18 at 10:57













  • Try to request it with explicit Content-Type header set to application/json

    – Alexey
    Nov 21 '18 at 11:14











  • Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

    – David Goate
    Nov 21 '18 at 11:19













  • @DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

    – happymeal
    Nov 21 '18 at 11:30











  • ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

    – David Goate
    Nov 21 '18 at 11:44
















0















When i access the url http://localhost:8080/test/testSpring, my spring boot app returned 404 error even though I have mapped the URL in my controller.



My REST service:



@RestController
public class TestSpring {
@RequestMapping(value="/test/testSpring", method=RequestMethod.GET)
public String test() {
return "test ok";
}
}


Console log shows URL is mapped:



RequestHandlerMapping - Mapped "{[/test/testSpring],methods=[GET]}" onto public java.lang.String ...









share|improve this question

























  • do you have context path property in application.properties? also attach screenshot of directory structure of project.

    – Alien
    Nov 21 '18 at 10:57













  • Try to request it with explicit Content-Type header set to application/json

    – Alexey
    Nov 21 '18 at 11:14











  • Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

    – David Goate
    Nov 21 '18 at 11:19













  • @DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

    – happymeal
    Nov 21 '18 at 11:30











  • ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

    – David Goate
    Nov 21 '18 at 11:44














0












0








0








When i access the url http://localhost:8080/test/testSpring, my spring boot app returned 404 error even though I have mapped the URL in my controller.



My REST service:



@RestController
public class TestSpring {
@RequestMapping(value="/test/testSpring", method=RequestMethod.GET)
public String test() {
return "test ok";
}
}


Console log shows URL is mapped:



RequestHandlerMapping - Mapped "{[/test/testSpring],methods=[GET]}" onto public java.lang.String ...









share|improve this question
















When i access the url http://localhost:8080/test/testSpring, my spring boot app returned 404 error even though I have mapped the URL in my controller.



My REST service:



@RestController
public class TestSpring {
@RequestMapping(value="/test/testSpring", method=RequestMethod.GET)
public String test() {
return "test ok";
}
}


Console log shows URL is mapped:



RequestHandlerMapping - Mapped "{[/test/testSpring],methods=[GET]}" onto public java.lang.String ...






java spring spring-boot jax-rs cxf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 22:04









Paul Samsotha

151k20291479




151k20291479










asked Nov 21 '18 at 10:56









happymealhappymeal

1,1581121




1,1581121













  • do you have context path property in application.properties? also attach screenshot of directory structure of project.

    – Alien
    Nov 21 '18 at 10:57













  • Try to request it with explicit Content-Type header set to application/json

    – Alexey
    Nov 21 '18 at 11:14











  • Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

    – David Goate
    Nov 21 '18 at 11:19













  • @DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

    – happymeal
    Nov 21 '18 at 11:30











  • ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

    – David Goate
    Nov 21 '18 at 11:44



















  • do you have context path property in application.properties? also attach screenshot of directory structure of project.

    – Alien
    Nov 21 '18 at 10:57













  • Try to request it with explicit Content-Type header set to application/json

    – Alexey
    Nov 21 '18 at 11:14











  • Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

    – David Goate
    Nov 21 '18 at 11:19













  • @DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

    – happymeal
    Nov 21 '18 at 11:30











  • ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

    – David Goate
    Nov 21 '18 at 11:44

















do you have context path property in application.properties? also attach screenshot of directory structure of project.

– Alien
Nov 21 '18 at 10:57







do you have context path property in application.properties? also attach screenshot of directory structure of project.

– Alien
Nov 21 '18 at 10:57















Try to request it with explicit Content-Type header set to application/json

– Alexey
Nov 21 '18 at 11:14





Try to request it with explicit Content-Type header set to application/json

– Alexey
Nov 21 '18 at 11:14













Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

– David Goate
Nov 21 '18 at 11:19







Are you accessing the application directly or via a reverse proxy like NGINX or Apache? Sometimes, if these are being matched in a location match (in NGINX terminology) which has a path prefix then the proxy request might contain the prefix, meaning that the actual request being asked is something like /something/test/testSpring

– David Goate
Nov 21 '18 at 11:19















@DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

– happymeal
Nov 21 '18 at 11:30





@DavidGoate, I'm accessing through localhost and using the default spring-boot embedded tomcat so I doubt there's any kind of proxy.

– happymeal
Nov 21 '18 at 11:30













ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

– David Goate
Nov 21 '18 at 11:44





ok thanks, yes in that case I doubt it too. It might be useful to share the output of curl -v http://localhost:8080/test/testSpring and any relevant logs that occur on the server.

– David Goate
Nov 21 '18 at 11:44












1 Answer
1






active

oldest

votes


















0














i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml






share|improve this answer























    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',
    autoActivateHeartbeat: false,
    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%2f53410595%2fspring-returning-http-404-even-though-url-is-mapped%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









    0














    i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml






    share|improve this answer




























      0














      i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml






      share|improve this answer


























        0












        0








        0







        i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml






        share|improve this answer













        i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 9 at 11:01









        happymealhappymeal

        1,1581121




        1,1581121
































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410595%2fspring-returning-http-404-even-though-url-is-mapped%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory