users@grizzly.java.net

Re: Session management bug / Static resource as stream

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 02 Sep 2008 17:36:08 -0400

Salut,

switching to users list.

Loic Petit wrote:
> Hi,
>
> I'm using the wicket framework with Grizzly. And I discovered that when
> the session manager wants to bind a session it raises an NPE in
> HttpSessionImpl.access() because there is no GrizzlySession attached
> (GrizzlySession.getSession(false) returned null). After some researchs I
> found the problem... The cookie containing the session id (JSESSIONID)
> is never parsed thus it is not possible for httpSession (in
> HttpServletRequestImpl) to be initialized.
>
> Here is what I have changed :
>
> in ServletAdapter:
>
> public void service(GrizzlyRequest request, GrizzlyResponse response) {
> ....
> if (httpRequest == null) {
> ....
>
> Cookie[] cookies = request.getCookies();
> if (cookies != null) for (Cookie c : cookies) {
> if
> (Constants.SESSION_COOKIE_NAME.equals(c.getName())) {
> request.setRequestedSessionId(c.getValue());
> request.setRequestedSessionCookie(true);
> break;
> }
> }
> httpRequest.initSession();
> ....
>
> in HttpServletRequestImpl :
>
> public void initSession() {
> GrizzlySession session = request.getSession(false);
> if (session != null) {
> httpSession = new HttpSessionImpl(contextImpl);
> httpSession.setSession(session);
> httpSession.access();
> }
> }
>
> It may not be at the right place into the whole project but for me it's
> working.

Can you send a svn diff? Better, just file an issue here:

https://grizzly.dev.java.net/issues/

and attach your patch. So far your changes looks good but just be be
100% sure.


>
>
> I also discovered that you use the class java.io.File for the static
> content. Thus you can't allow reading in jar files for example (it's my
> case) by passing an URI. To handle that I've build my own adapter to
> handle the static content with MyClass.class.getResourceAsStream. It's
> working but it's not that beautifull :s.

Can you share the code snipped you used? Just curious. I wonder how I
can determine from the StaticResourceAdapter if the application is
running inside a jar or not. I did some work on the ClassLoaderUtil:

https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/util/ClassLoaderUtil.html

I suspect I can improve to support what you are recommending.

>
> Do you plan to do handle them via URI ?

That's a really good point. Which Grizzly version are you using? I can
certainly give it a try. Can you file an RFE here:

https://grizzly.dev.java.net/issues/

Merci!

-- Jeanfrancois



>
> Enjoy !
>
> Loïc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: issues-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: issues-help_at_grizzly.dev.java.net
>