title: MessageBodyWriter not found for media type=application/xml
body: <p>I want to make a REST API Response in two formats depending on the HttpHeaders of the request : </p>
  
  <pre><code>@Context
  HttpHeaders headers; 
  
  public Response toResponse(MyValidationException exception) {
     if(headers.getMediaType().toString().equals(MediaType.APPLICATION_XML)){
       return Response.status(Status.BAD_REQUEST).entity(exception.getErrors()).type(MediaType.APPLICATION_XML).build();
    }else{
       return Response.status(Status.BAD_REQUEST).entity(exception.getErrors()).type(MediaType.APPLICATION_JSON).build();
  }}
  </code></pre>
  
  <p>It's working for the MediaType.APPLICATION_JSON, but for MediaType.APPLICATION_XML I get the following Error : </p>
  
  <pre><code>org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo MessageBodyWriter not found for media type=application/xml, type=class java.util.HashMap$EntrySet, genericType=class java.util.HashMap$EntrySet.
  </code></pre>
  
  <p>Any Idea to solve this problem?</p>