webtier@glassfish.java.net

Re: Glassfish v3 Drops sessions after a short amount of time

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Wed, 03 Mar 2010 11:16:11 -0800

Hi John,

in order to debug the kind of problem you are facing, I normally
implement an HttpSessionListener that prints (to the domain's
server.log) the id of the session being created and destroyed, along
with a stack trace, in response to the sessionCreated and
sessionDestroyed events it receives.

I've attached a sample implementation.

In addition to compiling and bundling the attached class in your
webapp's WEB-INF/classes directory, you also need to declare it in the
web.xml, as follows:

 <listener>
   <listener-class>MySessionListener</listener-class>
 </listener>

Alternatively, since you are using GlassFish v3 and therefore Servlet
3.0, you could annotate MySessionListener with
@javax.servlet.annotation.WebListener, in which case you would not have
to declare it.

Hopefully, this will give us some insight into why sessions are being
destroyed.

Let us know what you find.

Thanks,

Jan

Alexis Moussine-Pouchkine wrote:
> this is a question for the JSF/CDI folks, adding the webtier alias
> -Alexis
>
> On 3 mars 2010, at 13:25, glassfish_at_javadesktop.org wrote:
>
>
>> Hey all
>>
>> We've run in to a bit of an issue in our environment.
>>
>> We're using glassfish v3, with 2 domains running per box. The one thing that I've noticed, though inconsistent, is that glassfish will randomly drop sessions within the first 10 minutes. Doesn't matter if the user is idle or not. It's a JSF application, and every so often we'll receive a message "view could not be restored" which seems to indicate that the JSF state was lost.
>>
>> is there anyway to determine where it was supposed to be stored? I don't see any messages in the logs that indicate a failure here, just the sudden "view could not be restored." We are using CDI, and we've noticed that even session scoped beans are gone after this happens.
>> [Message sent by forum member 'johnament' (john.d.ament_at_gmail.com)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=389812
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>




import javax.servlet.http.*;

public class MySessionListener implements HttpSessionListener {

    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("SESSION WITH ID " + se.getSession().getId() +
            " CREATED");
        Thread.currentThread().dumpStack();
    }

    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("SESSION WITH ID " + se.getSession().getId() +
            " DESTROYED");
        Thread.currentThread().dumpStack();
    }
}