jersey
  1. jersey
  2. JERSEY-1531

Unable to mix inbound and outbound response on server side

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-m09
    • Fix Version/s: 2.0-m13, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      On a resource:

      @Path("resource")
      public class Resource {
      
      	public static final String MESSAGE = "any message which should be returned by other resource method";
      
      	@Uri("resource/other")
      	WebTarget target;
      	
      	@GET
      	@Path("uri")
      	public Response uri() {
      		Response response;
      		if (target == null)
      			response = Response.ok("injected WebTarget is null").build();
      		else
      			response = target.request().buildGet().invoke();
      		return response;
      	}
      	
      	@GET
      	@Path("other")
      	public String other() {
      		return MESSAGE;
      	}
      
      }
      

      Calling uri() method, the following exception occurs:

      java.lang.IllegalArgumentException: Unsupported response implementation type: org.glassfish.jersey.client.ScopedJaxrsResponse
      at org.glassfish.jersey.message.internal.OutboundJaxrsResponse.unwrap(OutboundJaxrsResponse.java:87)
      at org.glassfish.jersey.server.ContainerResponse.<init>(ContainerResponse.java:83)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:299)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:90)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:198)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:316)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:174)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:761)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:309)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:349)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:312)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:195)

      May be fixed by generally solving JERSEY-1516, though OutboundJaxrsResponse.unwrap() can count with ScopedJaxrsResponse directly.

        Issue Links

          Activity

          Hide
          jan.supol added a comment -

          Actually maybe not a bug, but feature. But it leads to a need of fetching all data from Client response and wrap them to a new response to be finally sent elsewhere from a resource method.

          Show
          jan.supol added a comment - Actually maybe not a bug, but feature. But it leads to a need of fetching all data from Client response and wrap them to a new response to be finally sent elsewhere from a resource method.

            People

            • Assignee:
              Marek Potociar
              Reporter:
              jan.supol
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3 hours
                3h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes Time Not Required
                30m