users@jersey.java.net

[Jersey] Question about multiple get methods with different "signatures"

From: Olivier Bourdon <olivierbourdon38_at_gmail.com>
Date: Mon, 15 Oct 2012 16:44:27 +0200

All

suppose I have the following procedure

@Path("/orgs")
...
   @Path("{oid}")
     @GET
     public Response org_get(@PathParam("oid") Long oid) {
...
}

and if I specify a string which can not be mapped into a Long like
GET /orgs/dummy

then I get back a 404 without even entering the org_get method. So far
this seems perfectly normal

However if I add another procedure like
@Path("{name}")
@GET
public Response org_get(@QueryParam("name") String name) {
...
}

then I get the following into my AppServer log:
2012-10-15 16:27:23.385+0200 (37) The following errors and warnings have
been detected with resource and/or provider classes:
   SEVERE: Producing media type conflict. The resource methods public
javax.ws.rs.core.Response
com.usharesoft.rest.resources.common.OrgsCResource.org_get(java.lang.String)
and public javax.ws.rs.core.Response
com.usharesoft.rest.resources.common.OrgsCResource.org_get(java.lang.Long)
can produce the same media type

This seems very strange to me as in one case Jersey seems perfectly able
to distinguish between the 2 signatures
Am I missing something ?

Note that I am currently using Jersey 1.10 as I did not have time yet to
migrate to 1.14

Many thanks