users@glassfish.java.net

Re: Jersey + JSON + JAXB + Natural

From: <glassfish_at_javadesktop.org>
Date: Wed, 18 Nov 2009 16:25:14 PST

Here is the solution:

You only need to change the configure method in your "JerseyTest" like this:

  @Override
  protected AppDescriptor configure() {
    setTestContainerFactory(new JettyWebTestContainerFactory("./src/main/webapp"));

                ClientConfig cc = new DefaultClientConfig();

                // IMPORTANT
                cc.getClasses().add(JAXBContextResolver.class);

    return new WebAppDescriptor.Builder("com.prototype.resources").clientConfig(cc).build();
  }

And that should be it.


so to be clear:

the jersey-server automatically register the ContextResolver found inside the resources package

however, for the jersey-client you MUST explicitly register the ContextResolver as shown above.


Many thanks to Jakub Podlesak for helping me understand this.
[Message sent by forum member 'hokusmokus' ]

http://forums.java.net/jive/thread.jspa?messageID=372445