Adam Bien's Weblog

Configuring JAXB Mapping On A JAX-RS 2.0 Client

Mapping of POJOs to XML needs to be configured on a JAX-RS 2.0 client with registering a feature class:

import org.glassfish.jersey.jackson.JacksonFeature;
import org.junit.Before;
import org.junit.Test;

public class MessagesResourceIT {

    private Client client;
    private WebTarget messagesTarget;

    public void initClient() {
        this.client = ClientBuilder.newClient().register(JacksonFeature.class);
        this.messagesTarget ="http://.../");

    public void allMessages() {
        Message response = this.messagesTarget.path("42").request().get(Message.class);
		//...asserts omitted

In addition you will also have to setup the dependency to the underlying framework (Jackson in this case):


JavaEE 7 JSON processing needs similar configuration as well.

See you at Java EE Workshops at MUC Airport!

NEW dates, new workshop: Java EE 7 Workshops: Bootstrap, Effective, Architectures, JavaScript Bootstrap and HTML 5 December, 7th-11th
NEW: Java EE 7 Testing-- Available For Streaming


A book about rethinking Java EE Patterns


I suppose there's an error in the title. It should be Jackson/JSON, rather than JAXB.

Posted by Matt Bukowicz on July 10, 2013 at 12:25 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments