On Mon, Apr 18, 2011 at 1:30 AM, Jason Erickson <jason_at_jasonerickson.com>wrote:
> Contrary to what Ryan says, you can use a query parameter to choose
> between two resources. In fact, in a way, that’s always what you’re doing
> if the query parameter actually affects what gets returned.
>
> Semantically, what you say is true. I was referring to a situation like
this in a resource class:
@GET
@Path("/foo")
public Foo getFoo(@QueryParam("x") int x) {
...
}
@GET
@Path("/foo")
public Foo getFoo(@QueryParam("y") String y) {
...
}
In the two versions of Jersey I've used--1.2 and 1.4--that doesn't work
because you're trying to bind two different methods to the same request
signature, so to speak. You get an error message like this:
INFO: Initiating Jersey application, version 'Jersey: 1.4 09/11/2010 10:30
PM'
Apr 18, 2011 9:45:47 AM com.sun.jersey.spi.inject.Errors
processErrorMessages
SEVERE: The following errors and warnings have been detected with resource
and/or provider classes:
SEVERE: Producing media type conflict. The resource methods public
com.foo.Foo com.foo.FooResource.getFoo(java.lang.String) and public
com.foo.Foo com.foo.FooResource.getFoo(int) can produce the same media type
Has something changed to allow that to work?
> Ryan,
>
> It is what it is. You build an application with the JAX-RS implementation
> you have, not the one you wish you had. Have you thought about using an
> ExceptionMapper? It doesn’t sound like quite the fit you are looking for,
> but maybe it’s close enough to work.
>
> But what exception would you map? Is it an exception that's eligible for
mapping that causes the 404 to be returned? That would be fine with me. Like
the OP, I just don't know how or where to trap this error and prevent the
404 from going out.