users@jersey.java.net

Re: [Jersey] Problem using Jersey client from openoffice java extension

From: Angel Luis Jimenez Martinez <soyangel_at_gmail.com>
Date: Tue, 29 Dec 2009 11:37:58 +0100

Wow, it works perfectly adding this line before calling any Jersey code.

For the record I was using 1.1.2-ea.

Thanks Paul.

On Tue, Dec 29, 2009 at 10:52 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi Angel,
>
> What version of Jersey are you using?
>
> I think this might be a class loading issue from within the OpenOffice
> environment. Jersey loads classes declared in META-INF/services files. From
> the log output it certainly finds those services files but it cannot find
> the classes declared in those files because ClassNotFoundException is
> thrown.
>
> Jersey uses the thread context class loader to load such classes. Perhaps
> you can do the following:
>
>
> Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
>
> Paul.
>
>
> On Dec 22, 2009, at 6:35 PM, Angel Luis Jimenez Martinez wrote:
>
> Hi,
>>
>> I'm trying to use Jersey client library from inside an Openoffice
>> extension. The problem is that this simple code desn't work:
>>
>> Client client = Client.create();
>> WebResource webResource = client.resource("
>> http://ws.audioscrobbler.com/2.0/");
>>
>> MultivaluedMap queryParams = new MultivaluedMapImpl();
>> queryParams.add("api_key", "LASTFM_API_KEY_HERE");
>> queryParams.add("method", "album.search");
>> queryParams.add("album", "believe");
>> String s =
>> webResource.queryParams(queryParams).get(String.class);
>> System.out.println(s);
>>
>> Of course I have tested this from a console java program (using the same
>> libraries) and works perfectly.
>>
>> I think that the problem is related to these messages outputted by
>> Openoffice when trying to execute this code:
>>
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> Dec 22, 2009 6:06:19 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.
>> terminate called after throwing an instance of
>> 'com::sun::star::uno::RuntimeException'
>>
>> As no more stack trace messages where available I attached eclipse to
>> debug this code and using jersey's source found some place where a
>> MediaTypeProvider was instanced as null. So I think the solution is related
>> to those warnings.
>>
>> If it helps I can provide a simple Netbeans project with this code.
>>
>> Thanks in advance.
>>
>> --
>> Angel.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>


-- 
Angel.