1

I have the following javax rs annotated interface:

@Path("/")
public interface MyRestEndpoint {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("myapp/resources/resourceId/{resourceId}/memberId/{memberId}")
    MyResource findMyResource(@PathParam("resourceId") int resourceId,
                                                  @PathParam("memberId") long memberId);

Which I am calling via a jersey proxy client created as such:

MyRestEndpoint myRestEndpointForTests = WebResourceFactory.newResource(MyRestEndpoint.class, lobbyClient().target(myHost));

...
myRestEndpointForTests.findMyResource(resourceId, memberId);

But when I do so, I get the following exception:

java.lang.IllegalStateException: Unresolved variables; only 0 value(s) given for 2 unique variable(s)
        at org.glassfish.jersey.client.JerseyWebTarget.getUri(JerseyWebTarget.java:134)
        at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:214)
        at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:59)
        at org.glassfish.jersey.client.proxy.WebResourceFactory.invoke(WebResourceFactory.java:312)
        at com.sun.proxy.$Proxy89.findCurrentTableOfPlayer(Unknown Source)

Having debugged somewhat through the Jersey codebase, it seems that the WebResourceFactory is trying to create a WebTarget by looping over the annotations on the MyRestEndpoint class. It picks up both annotations, and both provided values but seems to overwrite any previously resolved path params as it loops over them (so its left with only the memberId path param being resolved). Can anyone explain why? Is this a bug or expected behaviour? How can I support multiple path params?

I know this is specific to having more than one path parameter configured via annotation. As I have other methods in the annotated interface that have only one path parameter and work perfectly when called in the same way.

I'm using Jersey v2.16 components and Javax rs v2.0.1 components

James
  • 1,237
  • 4
  • 22
  • 43

1 Answers1

0

Looks like WebResourceFactory is not actively developed also it's source code was quite hard to understand for me.

So we created another implementation of proxing rest interfaces.

Feel free to try https://github.com/adaptris/jaxrs-client-proxy implementation. It's under development currently so for sure have some bugs.

irla
  • 479
  • 3
  • 13