users@jersey.java.net

[Jersey] Re: Jersey Client JSONRootElementProvider

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 07 Nov 2011 09:54:13 +0100

Hello Ronak,

You do not need to explicitly add the JSONRootElementProvider to your
client configuration.
It should be sufficient to just add the jersey-json module to your
dependencies.
I.e. just try to remove the following line from your code:
config.getClasses().add(JSONRootElementProvider.class);

Does it work? If not, could you please send some more details on what
you expect
and what you are getting instead?

Thanks,

~Jakub



On 6.11.2011 17:21, Ronak Patel wrote:
> Hello all,
>
> I've recently upgraded to Jersey 1.8 from 1.5 and am getting these
> exceptions:
>
> Nov 6, 2011 11:15:35 AM com.sun.jersey.spi.inject.Errors
> processErrorMessages
> SEVERE: The following errors and warnings have been detected with
> resource and/or provider classes:
> SEVERE: The class
> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider does
> not have a public constructor and cannot be instantiated.
> SEVERE: The class
> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider does
> not have a public constructor and cannot be instantiated.
> Exception in thread "main"
> com.sun.jersey.spi.inject.Errors$ErrorMessagesException
> at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
> at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
> at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
> at com.sun.jersey.api.client.Client.<init>(Client.java:187)
> at com.sun.jersey.api.client.Client.<init>(Client.java:170)
> at com.sun.jersey.api.client.Client.create(Client.java:679)
>
> When trying to run code:
>
> final ClientConfig config = new DefaultClientConfig();
> config.getClasses().add(JSONRootElementProvider.class);
> this.client = Client.create(config);
>
> Is this still correct in Jersey 1.8? Or do I have to switch to the
> POJO model?
>
> I need my services to remain using standard JAXBJSON Binding for
> backward compatibility reasons.
> I hope that is okay?
>
> Thanks for your help!
>
> Ronak Patel
>
>