• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Problem passing parameter in RequestMethod.GET in Spring Boot RELEASEs 1.3.3 , 2.0.4

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am currently trying to pick up Spring Boot for potential new job. I desperately  need help getting past the following server issues:

1. The Spring Boot Application basically works but it fails to pass the id parameter properly. In fact the non parameterized GETs e.g http://localhost:8080/api/v1/shipwrecks  works fine while the
parameterized:  http://localhost:8080/api/v1/shipwrecks/1  or  http://localhost:8080/api/v1/shipwrecks/2     fails to work returning:
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Sep 14 19:42:33 EDT 2018
There was an unexpected error (type=Bad Request, status=400).
Required request body is missing: public com.boot.model.Shipwreck com.boot.controller.ShipwreckController.get(java.lang.Long,com.boot.model.Shipwreck)

On the server side:
The WARNING PREFIXED BY THE info MESSAGES:
2018-09-14 19:53:55.159  INFO 14788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-09-14 19:53:55.177  INFO 14788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 18 ms
2018-09-14 19:53:55.238  WARN 14788 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.boot.model.Shipwreck com.boot.controller.ShipwreckController.get(java.lang.Long,com.boot.model.Shipwreck)

Has anyone seen this problem before? I have no duplicate EncodedURL entries as a similar problem owner claimed to have been his problem. I can find no such redundancies


Sample of the Controller code:
@RequestMapping(value = "shipwrecks/{id}", method = RequestMethod.GET)
public Shipwreck get(@PathVariable Long id,@RequestBody Shipwreck shipwreck) {
// tried: public @ResponseBody Shipwreck get(@PathVariable Long id,@RequestBody Shipwreck shipwreck) {
return ShipwreckStub.get(id);
}
 
Jack Silver
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following link allows a user to download this project at :
https://www.dropbox.com/s/vz2kx38jib5ztbb/das-boot1.3.3RELEASE.zip?dl=0


This version is a 1.3.3 Release version , however, by changing the Parent pom version to 2.0.4.RELEASE you will see the same output I am seeing. I tried this on Centos and Windows 10 machines thus far.
 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest that instead of providing a single compressed file for download that you post the code on a site like https://github.com that way anyone who wants to view the code and made edits can quickly with their own github account.
Currently, the link to the file you have provided could contain more then what is needed for the project or possibly may not contain the project at all.

Please take the time to use the code tags when provided code as stated here https://coderanch.com/wiki/659781/Code-Tags.

Sometimes colors in postings can be distracting, so generally you may want to use only one of the colors other then black.
Please keep in mind that not all people view all the colors as expected (color blind) or other possible issues.

Did the projects which you are working on locally on your system come from a tutorial somewhere? If so where?
By providing the location others could put the projects into it's proper context which could be very helpful.

I suggest that you stick with a newer version of Spring, something like 1.5 or maybe 2.0. I'm unsure if 1.3 is supported anymore, and there is an end date for 1.5.
 
Jack Silver
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the Code I am changing the pom.xml to reflect the 2.0.4.RELEASE. Please feel free to test this out and explain why
lwebpage   comes up with a 404 while http://localhost:8080/api/v1/shipwrecks displays a JSON  list please.
 
Jack Silver
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved the problem by recreating the project and adding @PathVariable("id")  before id in the parameterized GET request mapping. Also Cleaning the project and using 2.0.4.RELEASE
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!