users@jersey.java.net

[Jersey] Re: Jersey Client WebResource question

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Thu, 31 May 2012 16:14:14 +0200

Hello Kevin,

this doesn't seem to be related to thread you've used to post this message.

Anyway - WebResource should be thread safe, but you can try cache
JerseyClient instance and create new WebResource before using it (it is
pretty cheap, all "expensive" operations are done when creating client
instance).

Please let me know how it went.

Thanks,
Pavel

On 5/29/12 11:52 PM, Kevin Duffey wrote:
> Hi,
>
> I am trying to track down an issue and I am not sure if it's related
> to a similar issue I've seen sometimes with browsers. Basically, I am
> integrating one app with another via REST, the client app uses Jersey
> Client and creates a static WebResource instance at the start/deploy
> of the app. During development, I sometimes redeploy the rest service
> app. The IP/url does not change. When I do this, the rest call to the
> service no longer works using the client WebResource instance. If I
> redeploy the client app, it then works again. My gut is telling me
> somehow the client WebResource is no longer good because I redeployed
> the service app. I don't know if this is the case or not, but since
> the ip/url does not change, I am not sure why this would be a problem.
> My only guess is that the WebResource opens a stream to the server
> side and when I redeploy the server side, it gets closed. If this is
> the case, (or if not but the WebResource instance is no longer good),
> is there some way to detect/be notified that the instance of the
> WebResource is no good and recreate it? It's not null.. I don't get an
> NPE when reusing it.
>
> Thanks.
>
>
>
>
>
>