• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

[REST][SPRING BOOT] Can't hit the url of the REST API, error 404 is returned in the response JSON

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
I have an Controller Class with the following annotations


I have taken the contents of @RequestMapping("projects/v1") and @GetMapping("/resources") to construct the url and entered it in Postman
http://localhost:8084/resource-service/projects/v1/resources

In response I have gotten is this
{
   "timestamp": 1607569944112,
   "status": 404,
   "error": "Not Found",
   "message": "No message available",
   "path": "/resource-service/projects/v1/resources"
}
These are the entries in the Spring Boot Terminal in INTELLIj IDE after firing the request

2020-12-10 11:07:13.708  INFO 5784 --- [nio-8084-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-12-10 11:07:13.709  INFO 5784 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-12-10 11:07:13.734  INFO 5784 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 25 ms
2020-12-10 11:09:04.872  WARN 5784 --- [nio-8084-exec-3] o.s.web.servlet.PageNotFound             : No mapping for GET /resource-service/resources
2020-12-10 11:12:24.108  WARN 5784 --- [io-8084-exec-10] o.s.web.servlet.PageNotFound             : No mapping for GET /resource-service/projects/v1/resources

Can someone tell me what went wrong? Is there some configurations I need to do in application.yml or something?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not see /resource-service in your path. Can you try with http://localhost:8084/projects/v1/resources ?
 
Sheriff
Posts: 22716
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree. Unlike web applications deployed in a container like Tomcat, JBoss, etc, Spring Boot by default does not use a context path. It can be enabled, but you have to explicitly do this.
 
Robinson Francis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I removed the context-path from the url in Postman and it worked, thanks.
 
Madan Lal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robinson, if that answer worked can you please upvote it
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic