ERROR - REST - Jersey - org.glassfish.jersey.message.internal.ReaderInterceptorExecutor - MessageBodyReader not found for media type, HTTP Error 415 Unsupported media type

Error

org.glassfish.jersey.message.internal.ReaderInterceptorExecutor - MessageBodyReader not found for media type=application/xml, type=class javax.ws.rs.client.  , genericType=javax.ws.rs.client. . callChainId=


while hitting the post / put request through Jersey client.

Moreover getting HTTP Error 415 Unsupported media type as the response.

Error Type

Runtime during Jersey Service call.

Possible Resolution 1

Make sure that all the required dependencies have been added to the POM file.

Possible Resolution 2

The JAXBElement.class must be defined as ParametrizedType using GenericType.

@POST
@Path("postMethod")
@Consumes(MediaType.APPLICATION_XML)
  public void createPostCompletion(JAXBElement<MyDto> myDto){

or 

DTO class has been properly annotated with root element i.e @XMLRootElement

Possible Resolution 3

Make sure that the xml Post body is created properly  ( if we are requesting Post / Put methods using XML / JSON). We can try marshelling the XML or JSON using the respective object and then using that JSON / XML through the client.