• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help getting REST service to receive json and stop saying cannot find a mesage body reader or writer  RSS feed

Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am exhausted. I have tried for a couple days now to get something working with REST service.

I am making a non-gui REST solution used to receive from whatever REST client people will use some json to create a ticket. I did not plan to run this in Tomcat or Weblogic. The issue is it receives the JSON and then shows the content on stdout, but it then throws if I just try and put String ticket in :

Starting http server
May 06, 2016 11:26:41 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
May 06, 2016 11:26:42 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class com.sas.msds.des.servicenow.ChangeticketRESTResource
May 06, 2016 11:26:42 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
May 06, 2016 11:26:42 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:42 PM'
May 06, 2016 11:26:48 AM com.sun.jersey.spi.container.ContainerRequest getEntity
SEVERE: A message body reader for Java class java.lang.String, and Java type class java.lang.String, and MIME media type applicati
on/json was not found.
The registered message body readers compatible with the MIME media type are: // If I try and receive in POST ChangeTicket ticket instead of String ticket, it complains instead about no writer.
*/* ->

I have no clue on how to setup providers, message body readers, or message body writers. I am not sure about the right dependencies or order to put them in pom.xml.

It starts a HttpServer and listens on a port.
It has a class called ChangeTicket, which is basically public ChangeTicket() with a lot of set and gets for things to make a ticket. It does have an @override for toString() that returns the json used to make a ticket.

Then, there is a class called ChangeticketRESTResource with:

There is web.xml:

and a pom.xml for maven:

Ron McLeod
Saloon Keeper
Posts: 1601
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It lloks like the problem is that in line 28 you state that MediaType.APPLICATION_JSON type entity will be produced/returned, but in line 41 you are actually returning a String.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!