users@jersey.java.net

[Jersey] Re: Jersey Client API in GlassFish b51

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 29 Aug 2012 12:03:02 +0200

The first scenario should not work. The second scenario should, provided you are injecting the WebTarget into a resource and not the servlet. If that's the case, then please file a bug.

Thanks,
Marek

On Aug 29, 2012, at 2:06 AM, Arun Gupta <Arun.p.Gupta_at_oracle.COM> wrote:

> With GlassFish build 51, I created a trivial resource as:
>
> @Path("/myresource")
> public class MyResource {
>
> @GET
> public String get() {
> return "Hello World!";
> }
> }
>
> And accessed this resource within a Servlet.doGet as:
>
> client.target(RESOURCE_ENDPOINT).request().get(String.class)
>
> If RESOURCE_ENDPOINT is "http://localhost:8080/Jersey2Sample/webresources/myresource"; then it works. A relative URI does not work and throws the error:
>
> InvocationException{message=URI is not absolute, response=null}
> at org.glassfish.jersey.client.ClientConfig$State$4$1.failure(ClientConfig.java:416)
> at org.glassfish.jersey.process.internal.ResponseProcessor.notifyCallback(ResponseProcessor.java:324)
> at org.glassfish.jersey.process.internal.ResponseProcessor.setResult(ResponseProcessor.java:309)
> at org.glassfish.jersey.process.internal.ResponseProcessor.access$400(ResponseProcessor.java:83)
> at org.glassfish.jersey.process.internal.ResponseProcessor$1.run(ResponseProcessor.java:214)
> at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:283)
> at org.glassfish.jersey.process.internal.ResponseProcessor.run(ResponseProcessor.java:188)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
>
> Why ?
>
> If the same endpoint is accessed as:
>
> @Uri("/webresources/myresource")
> WebTarget resource;
>
> resource.request().get()
>
> then a NPE is thrown. The "resource" object is not injected.
>
> Is this functionality implemented and integrated ?
>
> Thanks,
> Arun
>
>
> --
> http://twitter.com/arungupta
> http://blogs.oracle.com/arungupta
>