users@jersey.java.net

Re: [Jersey] Client Help

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 09 Jun 2010 06:58:41 +0200

Hi Scott,

The errors are related to Jersey not being able to find some classes
whose names are declared in a META-INF/services file (present in the
jeresy-core jar).

This could be because of re-package issues. Have you re-packaged
Jersey classes?

Or it could be related to class loading issues. How are you running
the client?

Jersey attempts to load the classes using the thread context class
loader [*]. One thing you can try is to set the thread context class
loader before you create the Client.

Paul.

[*] i think i need to change loading to fall back to the defining
class loader of the currently class if look up fails, but i do not
know if that will solve your problem.

On Jun 8, 2010, at 9:58 PM, Scott Glass wrote:

> I’ve written a small program to call a REST Web Service written in
> Jersey. The service works, and responds with a JSONObject as
> expected.
> But the client keeps throwing warnings and exceptions…
>
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.LocaleProvider implementing
> the provider interface com.sun.jersey.spi.HeaderDelegateProvider is
> not found. The provider implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.EntityTagProvider
> implementing the provider interface
> com.sun.jersey.spi.HeaderDelegateProvider is not found. The provider
> implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.MediaTypeProvider
> implementing the provider interface
> com.sun.jersey.spi.HeaderDelegateProvider is not found. The provider
> implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.CacheControlProvider
> implementing the provider interface
> com.sun.jersey.spi.HeaderDelegateProvider is not found. The provider
> implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.NewCookieProvider
> implementing the provider interface
> com.sun.jersey.spi.HeaderDelegateProvider is not found. The provider
> implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.CookieProvider implementing
> the provider interface com.sun.jersey.spi.HeaderDelegateProvider is
> not found. The provider implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.URIProvider implementing
> the provider interface com.sun.jersey.spi.HeaderDelegateProvider is
> not found. The provider implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.DateProvider implementing
> the provider interface com.sun.jersey.spi.HeaderDelegateProvider is
> not found. The provider implementation is ignored.
> Jun 8, 2010 3:56:28 PM com.sun.jersey.spi.service.ServiceFinder
> $LazyObjectIterator hasNext
> WARNING: The class
> com.sun.jersey.core.impl.provider.header.StringProvider implementing
> the provider interface com.sun.jersey.spi.HeaderDelegateProvider is
> not found. The provider implementation is ignored.
>
> com.sun.jersey.api.client.ClientHandlerException:
> java.lang.NullPointerException
> at
> com
> .sun
> .jersey
> .client
> .urlconnection
> .URLConnectionClientHandler.handle(URLConnectionClientHandler.java:
> 128)
> at com.sun.jersey.api.client.Client.handle(Client.java:551)
> at
> com.sun.jersey.api.client.WebResource.handle(WebResource.java:556)
> at com.sun.jersey.api.client.WebResource.access
> $200(WebResource.java:69)
> at com.sun.jersey.api.client.WebResource
> $Builder.get(WebResource.java:451)
> at
> com
> .sungard
> .cto
> .arsystem
> .plugin.SunGardUpdateService.createEntry(SunGardUpdateService.java:
> 199)
> at com.bmc.arsys.pluginsvr.plugins.a.ArdbcCreate(Unknown
> Source)
> at com.bmc.arsys.pluginsvr.a.ArEsArdbcCreate_4(Unknown Source)
> at
> com
> .bmc.arsys.arrpc.ARPluginServerDispatcher.dispatchOncRpcCall(Unknown
> Source)
> at
> org
> .acplt
> .oncrpc
> .server.OncRpcTcpConnectionServerTransport.dispatchCall(Unknown
> Source)
> at com.bmc.arsys.pluginsvr.a.d.dispatchCall(Unknown Source)
> at
> org
> .acplt
> .oncrpc.server.OncRpcTcpConnectionServerTransport._listen(Unknown
> Source)
> at
> org.acplt.oncrpc.server.OncRpcTcpConnectionServerTransport.access
> $000(Unknown Source)
> at org.acplt.oncrpc.server.OncRpcTcpConnectionServerTransport
> $1.run(Unknown Source)
> Caused by: java.lang.NullPointerException
> at javax.ws.rs.core.MediaType.toString(MediaType.java:265)
> at
> com
> .sun
> .jersey.api.client.ClientRequest.getHeaderValue(ClientRequest.java:
> 223)
> at
> com
> .sun
> .jersey
> .api
> .client
> .TerminatingClientHandler
> .headerValueToString(TerminatingClientHandler.java:229)
> at
> com
> .sun
> .jersey
> .client
> .urlconnection
> .URLConnectionClientHandler
> .writeOutBoundHeaders(URLConnectionClientHandler.java:227)
> at
> com
> .sun
> .jersey
> .client
> .urlconnection
> .URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:
> 172)
> at
> com
> .sun
> .jersey
> .client
> .urlconnection
> .URLConnectionClientHandler.handle(URLConnectionClientHandler.java:
> 126)
> ... 13 more
>
> Here’s the code for the client…
>
> ClientConfig config = new DefaultClientConfig();
>
> myClient = Client.create(config);
>
> WebResource resource = myClient.resource(“http://portal-dev2.sgns.net:8181/Case/create
> ”);
>
> MultivaluedMap map = new MultivaluedMapImpl();
>
> map.add("Format", "json");
> map.add("IncidentID", " HD0000001042502");
> map.add("CreateDate", " 2009-07-01 16:47");
>
> resource = resource.queryParams(map);
>
> /* resource.getURI().toString() returns http://portal-dev2.sgns.net:8181/Case/create?IncidentID=HD0000001042502&Format=json&CreateDate=2009-07-01+16:47
> which works.*/
>
> /* Line 199 */
> Object object =
> resource
> .accept(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class);
>
> Can anyone please shed some light as to what’s causing this? I’ve
> read pretty much everything I can get my hands on, but I’m at a loss.
>
> Thanks,
> Scott
>