This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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

 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • 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: 21864
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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: 351
  • Mark post as helpful
  • send pies
  • 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.
 
Ranch Hand
Posts: 82
1
VI Editor Java Linux
  • Mark post as helpful
  • send pies
  • 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: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was a package naming error.  I think I got it figured out now.
 
Nathan Milota
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • 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: 21864
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!