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