Note that there are some explanatory texts on larger screens.

plurals
  1. POMarshalling List<T> with Jersey and JAXB
    primarykey
    data
    text
    <p>I try to output some list of documemts from a resource:</p> <pre><code>@GET @Produces({MediaType.APPLICATION_XML}) public Response getDocuments(@QueryParam("provider") String provider) { List&lt;Document&gt; documents = service.getDocuments(provider); return Response.ok( new GenericEntity&lt;List&lt;Document&gt;&gt;( new ArrayList&lt;Document&gt;(documents)) {}) .build(); } </code></pre> <p>The Document class is not annotated with @XmlElement (I really dislike annotating my nice objects with such low-level stuff...) but I have a registered provider for it:</p> <pre><code>@Service @Provider @Produces({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.WILDCARD}) @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.WILDCARD}) public class JaxRsDocumentSerializer extends AbstractMessageReaderWriterProvider&lt;Document&gt; { </code></pre> <p>When I call this resource using a client with following code:</p> <pre><code>return getResource().path("/documents") .queryParam("provider", provider) .accept(MediaType.APPLICATION_XML).get(new GenericType&lt;List&lt;Document&gt;&gt;() {}); </code></pre> <p>I get the dreaded exception:</p> <pre><code> javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.ArrayList, and Java type java.util.List&lt;com.polyspot.model.core.Document&gt;, and MIME media type application/xml was not found </code></pre> <p>I do not understand what's wrong here as I followed code I found elsewhere, including in SO.</p> <p>Help greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload