users@jersey.java.net

Re: [Jersey] Problem with injected HttpServletRequest proxy

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 08 Dec 2009 13:46:56 +0100

On Dec 8, 2009, at 1:36 PM, Ian Carr wrote:

> Yep, good one, I had also left out the try catch in the handler I
> wrote in my Filter, adding it in the behavior is as expected!
>

Great. I am currently testing a fix locally that i will commit later
today.


> I don't suppose that will make it into the GF release?, is there a
> way I can use an alternate implementation of Jersey from WEB-INF/lib?

You can use the workaround i previously indicated, namely do:

@POST
@Path("login")
@Consumes( { MediaType.APPLICATION_JSON })
public void loginUser(@Context ThreadLocal<HttpServletRequest> req,
UIdent ident) {
        try {
                // does the login work?
                String uname = ident.getUname();
                String pword = ident.getPword();
                req.get().login(uname, pword);
        } catch (ServletException ex) {
                __log.info("Failed login attempt", ex);
                throw new WebApplicationException(Status.UNAUTHORIZED);
        }
}


This will not make it into GF until we release 1.1.5 and then it will
be available using the update centre. I would like to make available
SNAPSHOT releases in the update centre as well but currently we do not
allow that, i am not sure why as there should not be any technical
impediments to such a solution.

If you do not want to utilize the workaround then in the interim you
can use 1.1.5-ea-SNAPSHOT jars in the war, just make sure you have set
the class loader delegation to false in the sun-web.xml. You might see
a couple of exceptions occurring on deployment but it should not
effect the running of the application (the problem is that GF,
currently, cannot properly isolate web applications and Jersey's use
of META-INF/services requires that).

Paul.