Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Cannot serialize Spring Data object in Jersey using JAXB

$
0
0
I have a RESTful web service written with Apache Jersey 1.17. It is defined as follows:

Code:

@GET
@Produces({ APPLICATION_JSON, APPLICATION_XML })
public Page<Document> findDocuments(
        @QueryParam("") final DocumentSearchCriteria searchCriteria)

It just performs a query and returns a pageable list of documents. It uses Spring Data JPA and the pageable object is part of the Spring Data Commons library.

Everything works fine until the point of serializing the output of the list to JSON or XML format. Jersey is configured to use the JAXB approach and the Spring Data repository abstractions return the correct data.

The error that I get is:

Quote:

A message body writer for Java class org.springframework.data.domain.PageImpl, and Java type org.springframework.data.domain.Page<>, and MIME media type application/json was not found
I saw that Spring Data has JAXB adapters that should take care of serializing the Pageable objects so I am wondering if this feature comes out of the box or if there is some additional configuration needed because I haven't used JAXB before.

So the question is how to serialize the Spring Data objects using JAXB?

Thanks.

Viewing all articles
Browse latest Browse all 297

Trending Articles