users@jersey.java.net

Re: [Jersey] Re: custom serializer not getting called

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 17 Sep 2010 07:31:53 -0700

Hi James,

You should also be able to set the feature on the client side too:

   ClientConfig cc = new DefaultClientConfig();
   cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);

Jakub, can you update the JavaDoc of FEATURE_POJO_MAPPING and the user
guide?

Paul.

On Sep 16, 2010, at 12:20 PM, jameskpublic wrote:

>
> nm.
> I was looking at the wrong example.
> Just as a note, it's not at all clear from the docs that there are two
> separate json processors that can be configured, nor is it clear which
> classes and configs (context providers, FEATURE_POJO_MAPPING options
> and
> such) go with each of the json processors. (e.g. Is JSONJAXBContext
> for
> jackson?)
> I was looking the jsonfromjaxb example all the while thinking it was
> jackson
> when it wasn't.
>
> For anyone else trying to do a jackson unit test on both the client
> and the
> server, you have to configure the unit test to start the grizzley
> server in
> jackson mode:
>
> public class MainTest extends JerseyTest {
>
> public MainTest() {
> super(new WebAppDescriptor.Builder("javax.ws.rs.Application",
> MyApplication.class.getName())
> .initParam(JSONConfiguration.FEATURE_POJO_MAPPING,
> "true").build());
> }
> ...
> }
>
> but you also have to configure a client to do jackson serialization:
>
> @Override
> public void setUp() throws Exception {
> // TODO Auto-generated method stub
> super.setUp();
>
> ClientConfig cc = new DefaultClientConfig();
> cc.getClasses().add(JacksonJsonProvider.class);
> Client clientWithJacksonSerializer = Client.create(cc);
> resource = clientWithJacksonSerializer.resource(getBaseURI());
> }
>
> It took me a while to put those two things together. :)
> Hope that helps someone!
> James
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/custom-serializer-not-getting-called-tp5534150p5540037.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>