users@jersey.java.net

Re: [Jersey] Problem using jersey client in Junit test

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 30 Apr 2009 12:59:33 +0200

On Apr 30, 2009, at 6:29 AM, Gavin Bong wrote:

> I invoke a jersey PUT with the following configuration
>
> ClientConfig config = new DefaultClientConfig();
> config.getClasses().add( JSONRootElementProvider.class );

Why are you explicitly registering JSONRootElementProvider? You do not
need to do that.

When you include jersey-json in the classpath the JAXB/JSON providers
are automatically registered (which are static inner sub-classes of
JSONRootElementProvider, hence why you get an error when you register
that class, because Jersey does not know how to instantiate it).

The registration, although throwing an exception, should not stop the
JSON stuff working.

Paul.

>
> Client client = Client.create(config);
>
> But it is throwing an exception:
>
> Apr 30, 2009 12:22:12 PM
> com.sun.jersey.core.spi.component.ProviderFactory
> __getComponentProvider
> SEVERE: The provider class, class
> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider,
> could not be instantiated. Processing will continue but the class will
> not be utilized
> java.lang.InstantiationException:
> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider
> at java.lang.Class.newInstance0(Class.java:340)
>
> My pom file snippet:
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-client</artifactId>
> <version>1.0.3</version>
> <scope>test</scope>
> </dependency>
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-json</artifactId>
> <version>1.0.3</version>
> <scope>test</scope>
> </dependency>
>
> Am I missing anything else ?
>
> --
> Sincères salutations,
>
> Gavin Bong
>
> Rien ne sert d'être vivant, s'il faut qu'on travaille - André Breton
> If you do things well, do them better. Be daring, be first be
> different, be just. - Anita Roddick
> http://twitter.com/chihiro
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>