-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Rest service with Spring Boot and Jersey incorrectly returns HTTP Status 404 when resource exist and method is not allowed #3132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I noticed this as well. The interesting thing is that response still returns the Allow header with the proper methods, so I assume the status is just being set incorrectly somewhere. Also, I'm not sure whether this is part of the same issue. But I can't seem to get 405, 406, or 415 errors either, unless I use the same workaround. There has to be some configuration with the root handler that I'm missing. Update: Found a link: #2025. And a workaround for myself: It seems like changing the dependency from spring-boot-starter-web to spring-boot-starter-jersey fixes the issue. Here are the lines that are different during server startup.
|
You can map the API to The workaround described by @candlejack297 switches off the auto-configuration of Spring MVC so it's no longer mapped to |
Hi!
Description
I've developed a small Rest API using Spring Boot and Jersey. It seems to work well except for when calling the Rest API with a method that is not allowed, i.e calling the service with PUT and only GET is allowed. This leads to a HTTP 404 Not Found instead of HTTP 405 Method Not Allowed.
Workaround
Setting an alternative base path using @ApplicationPath, i.e. @ApplicationPath("/api") results in HTTP 405 Method Not Allowed as expected.
It should be possible to map the api to / using Jersey.
Thanks!
The text was updated successfully, but these errors were encountered: