• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Getting 404 Not Found when trying to do a GET method request in PostMan (RestController)

 
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure why, but when I type in http://localhost:8080/schools, it is getting a response from the server that the local host is running, but I set up the RestController and set the value to "schools", it won't find anything.

It is almost identical to another program I made which it works fine, but for some reason, it will not find it on here, and I was wondering if there is an error in the class that might make this happen.

I have all the same dependencies that I had in another program that works, so I don't know what it is about this.


 
Sheriff
Posts: 22650
126
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
Change the @RequestMapping on getAllSchools to @GetMapping. @RequestMapping by default has no method specified, so it won't listen to any request.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Change the @RequestMapping on getAllSchools to @GetMapping. @RequestMapping by default has no method specified, so it won't listen to any request.



For some reason, that still didn't work.  

I don't know if that's it, as I never used GetMapping on the other classes that are almost identical to this one, and those work fine.  Something else is wrong as I tried a test class, and it still isn't working right.  




It's returning an error saying it couldn't find a route, and does the same error if I type something that doesn't exist at all.
 
Rancher
Posts: 98
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Change the @RequestMapping on getAllSchools to @GetMapping. @RequestMapping by default has no method specified, so it won't listen to any request.



I wouldn't be so sure about that. I found regarding that this:


@RequestMapping – the HTTP Method
The HTTP method parameter has no default – so if we don't specify a value, it's going to map to any HTTP request.



I tried it out myself, seems to be true. So that's not a real problem.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It was a package naming error.  I think I got it figured out now.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class itself was done right.  It was that I had it in a package where there was no route to it.   The package needs to have the same path mine now are

io.ticket
and
io.ticket.school


It works that way.
 
Rob Spoor
Sheriff
Posts: 22650
126
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

Miroslav Lehotsky wrote:

Rob Spoor wrote:Change the @RequestMapping on getAllSchools to @GetMapping. @RequestMapping by default has no method specified, so it won't listen to any request.



I wouldn't be so sure about that. I found regarding that this:


@RequestMapping – the HTTP Method
The HTTP method parameter has no default – so if we don't specify a value, it's going to map to any HTTP request.



I tried it out myself, seems to be true. So that's not a real problem.


I guess I should check the Javadoc instead of just the source code
 
My, my, aren't you a big fella. Here, have a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic