This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404 - Not Found in Jersey  RSS feed

 
Alejandro Barrero
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My class is:

http://localhost:8084/GetSomeRest/webresources/service works and displays "Get some REST!". However, I get the 404 with "http://localhost:8084/GetSomeRest/webresources/service/track". I am a newbie and I don't know what is wrong with method getTrackInJSN.
 
Alejandro Barrero
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It also fails with "@Produces({MediaType.APPLICATION_JSON})" with exception "org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class com.vichargrave.Track, genericType=class com.vichargrave.Track.".
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, by default and if possible, Jersey will convert any java object into any text (json,xml, etc...) and return back to the client.
It works for GET/String.
It did not work for GET/Track because it does not know how to convert Track into json format.

When it can not it throw the exception unless you tell jersey what to do.

Read doc Jersey 2.4 User Guide
Chapter 8. Support for Common Media Type Representations
 
Alejandro Barrero
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks H Paul; Jersey 2.4 User Guide has a welt of information. However, I still have a problem; I coded the method as explained in the guide but I get "The requested URL "http://localhost:8084/GetSomeRest/webresources/service/track" cannot be found or is not available.". I tried to add @XmlRootElement to the class, as in the guide, but Netbeans does not recognize it. Perhaps I need to add a jar file but I don't know which; the guide does not mention jar files.
 
Alejandro Barrero
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using:


I am still getting the same error.
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read Doc:

Media modules that support this approach are MOXy and Jackson

8.1.2. MOXy

8.1.4. Jackson

Use either one. Make sure the jars are on the classpath.

Edited:

Assume the server side is setup correctly, you also need to send to the server a header:

accept: application/json
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!