2

I've created a Jersey POST API, that is getting text/plain as the body. I've tried this API locally and it was working as expected, but after deploying it to a server, I get 415 Unsupported Media Type.

This is the code:

@POST
@Path("/dodo")
@Consumes({MediaType.TEXT_PLAIN})
@Produces({MediaType.APPLICATION_JSON})
public Response Dodo(String input){
    return Response.status(200).entity(new JerseyDto(input,12)).build();
}

This is the error I see in the log:

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 text/plain was not found.
The registered message body readers compatible with the MIME media type are:
*/* ->
  com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider

Any thoughts?

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Mork
  • 23
  • 4

1 Answers1

0

Well, I found out what the problem was. We are using shade plugin in order to create a "fat" jar (includes all the dependencies), and there is a problem with Jersey when using this plugin. This is the reason why it was ok when running it locally. You can read more about this problem and the solution here.

Mork
  • 23
  • 4