Issue Details (XML | Word | Printable)

Key: JERSEY-1402
Type: Bug Bug
Status: Resolved Resolved
Resolution: Works as designed
Priority: Minor Minor
Assignee: Pavel Bucek
Reporter: arungupta
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jersey

Relative URI are not working for WebTarget injection

Created: 31/Aug/12 04:47 PM   Updated: 29/May/13 01:34 PM   Resolved: 11/Oct/12 03:31 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0-m09, 2.0

Time Tracking:
Not Specified

Tags:
Participants: arungupta and Pavel Bucek


 Description  « Hide

Injecting a WebTarget in another JAX-RS resource as:

@Path("myresource2")
public class MyResource2 {
public static final String RESOURCE_ENDPOINT = "/Jersey2Sample/webresources/myresource";

@Uri(RESOURCE_ENDPOINT)
WebTarget resource;

@GET
public String get() { return resource.request().get(String.class) + "2"; }

When this resource is accessed using GET, then the following exception is thrown:

SEVERE: InvocationException{message=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2, response=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2}
org.glassfish.jersey.internal.MappableException: InvocationException{message=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2, response=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2}
at org.glassfish.jersey.server.model.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:122)
at org.glassfish.jersey.server.model.AbstractJavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(AbstractJavaResourceMethodDispatcherProvider.java:219)
at org.glassfish.jersey.server.model.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:262)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:82)
at org.glassfish.jersey.process.internal.RequestInvoker$AcceptingInvoker.apply(RequestInvoker.java:241)
at org.glassfish.jersey.process.internal.AsyncInflectorAdapter.apply(AsyncInflectorAdapter.java:156)
at org.glassfish.jersey.process.internal.RequestInvoker$2.run(RequestInvoker.java:188)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:283)
at org.glassfish.jersey.process.internal.RequestInvoker$3.run(RequestInvoker.java:201)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:44)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:41)
at org.glassfish.jersey.process.internal.RequestInvoker.apply(RequestInvoker.java:197)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:752)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:309)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:312)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:195)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1593)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:285)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:660)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:600)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:337)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:240)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:172)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:815)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
at java.lang.Thread.run(Thread.java:722)
Caused by: InvocationException{message=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2, response=org.glassfish.jersey.client.InboundJaxrsResponse@50506ea2}
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:682)
at org.glassfish.jersey.client.JerseyInvocation.access$400(JerseyInvocation.java:72)
at org.glassfish.jersey.client.JerseyInvocation$2.completed(JerseyInvocation.java:605)
at org.glassfish.jersey.client.JerseyInvocation$2.completed(JerseyInvocation.java:587)
at org.glassfish.jersey.client.ClientConfig$State$4$1.result(ClientConfig.java:410)
at org.glassfish.jersey.client.ClientConfig$State$4$1.result(ClientConfig.java:405)
at org.glassfish.jersey.process.internal.ResponseProcessor.notifyCallback(ResponseProcessor.java:315)
at org.glassfish.jersey.process.internal.ResponseProcessor.setResult(ResponseProcessor.java:301)
at org.glassfish.jersey.process.internal.ResponseProcessor.access$600(ResponseProcessor.java:83)
at org.glassfish.jersey.process.internal.ResponseProcessor$1.run(ResponseProcessor.java:243)
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)
... 1 more

Changing the RESOURCE_ENDPOINT to an absolute URL returns the appropriate response. Changing the value to "myresource" works fine too.

Filing a bug as mentioned on the users list at: http://java.net/projects/jersey/lists/users/archive/2012-08/message/128



Marek Potociar made changes - 03/Sep/12 10:51 PM
Field Original Value New Value
Fix Version/s 2.0 [ 15271 ]
Fix Version/s 2.0-unplanned [ 15288 ]
Pavel Bucek made changes - 04/Sep/12 09:24 AM
Fix Version/s 2.0-m08 [ 16006 ]
Fix Version/s 2.0-unplanned [ 15288 ]
Marek Potociar made changes - 04/Sep/12 05:28 PM
Original Estimate 3 hours [ 10800 ]
Remaining Estimate 3 hours [ 10800 ]
Marek Potociar made changes - 21/Sep/12 03:58 PM
Fix Version/s 2.0-m09 [ 16050 ]
Fix Version/s 2.0-m08 [ 16006 ]
Pavel Bucek made changes - 10/Oct/12 12:08 PM
Assignee Pavel Bucek [ pavel_bucek ]
Pavel Bucek made changes - 10/Oct/12 12:08 PM
Status Open [ 1 ] In Progress [ 3 ]
Pavel Bucek added a comment - 10/Oct/12 12:16 PM

when relative Uri is provided, Jersey completes it by adding context path of deployed application. In your case it ends up with someting like:

"/Jersey2Sample/webresources/Jersey2Sample/webresources/myresource"

so I don't really see what should be fixed or improved here, since other mentioned cases are ok.


Pavel Bucek added a comment - 11/Oct/12 03:31 PM

works as designed. @Uri javadoc was adjusted to be more clear about resolving relative uris.


Pavel Bucek made changes - 11/Oct/12 03:31 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Works as designed [ 7 ]
Marek Potociar made changes - 29/May/13 01:34 PM
Original Estimate 3 hours [ 10800 ] 0 minutes [ 0 ]
Remaining Estimate 3 hours [ 10800 ] 0 minutes [ 0 ]