Announcement Announcement Module
No announcement yet.
Cannot serialize Spring Data object in Jersey using JAXB Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot serialize Spring Data object in Jersey using JAXB

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

    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:

    A message body writer for Java class, and Java type<>, 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?