Jersey, Guice usando rutas de solicitud no root

I'm using Jersey 1.11 over Guice 3.0 on Tomcat 6.0.32 in a standard configuration:

configureServlets() {

And a simple resource class:

public class Resource { ... }

Given that, I would suppose that accessing "/ws/resource" would work; but actually no resources are found. The problem seems to lie in the request path not being computed correctly. As a workaround I have set the parameter PROPERTY_FILTER_CONTEXT_PATH a /ws, which make the whole thing work:

Map<String, String> jerseyConfig = new HashMap<String, String>();
jerseyConfig.put(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, "/ws");
filter("/ws/*").through(GuiceContainer.class, jerseyConfig);

Entonces mis preguntas son:

  1. Is this really a bug or a "feature" ?
  2. Is there another solution or workaround for this?

For info, I've seen one Guice bug that can be related, it seems to have been merged in another one but I'm wondering if it's properly fixed (enlace)

preguntado el 01 de febrero de 12 a las 14:02

1 Respuestas

Use serve instead of filter.

configureServlets() {

You will then be able to hit /ws/resource.

respondido 05 mar '12, 16:03

Thanks, it works (I wouldn't have thought that you could also necesitar a filtrar). server() debe leerse como serve(). - Laurent Grégoire

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.