Spring returning HTTP 404 even though URL is mapped
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
|
show 2 more comments
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
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 explicitContent-Type
header set toapplication/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 ofcurl -v http://localhost:8080/test/testSpring
and any relevant logs that occur on the server.
– David Goate
Nov 21 '18 at 11:44
|
show 2 more comments
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
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
java spring spring-boot jax-rs cxf
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 explicitContent-Type
header set toapplication/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 ofcurl -v http://localhost:8080/test/testSpring
and any relevant logs that occur on the server.
– David Goate
Nov 21 '18 at 11:44
|
show 2 more comments
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 explicitContent-Type
header set toapplication/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 ofcurl -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
|
show 2 more comments
1 Answer
1
active
oldest
votes
i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml
add a comment |
i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml
add a comment |
i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml
i resolved the issue by using different url pattern for the jax-rs and spring servlets in my web.xml
answered Jan 9 at 11:01
happymealhappymeal
1,1581121
1,1581121
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 toapplication/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