How to Disable Persisting of Memory-based HTTP Sessions during a Server Restart

How to Disable Persisting of Memory-based HTTP Sessions during a Server Restart

How to Disable Persisting of Memory-based HTTP Sessions during a Server Restart

When stopping your Glassfish server, all memory-based HTTP sessions created by web applications deployed on your server are persisted into files using serialization, and restored from their serialized format during a subsequent restart of the server, after which the files containing the serialized sessions are deleted.

Only those sessions that are still valid (i.e., have not yet expired) at the time the server is stopped are subject to being persisted.

The HTTP sessions are persisted for each web application individually, in this file:

  ${GF_HOME}/domains/domain1/generated/jsp/j2ee-modules/<module_name>/<context_path>_SESSIONS.ser

where ${GF_HOME} points to your Glassfish installation directory, <module_name> is the name of your web application, and <context_path> is the context path at which your web application has been deployed.

If your web application is bundled inside an EAR file, its sessions will be persisted in this file:

  ${GF_HOME}/domains/domain1/generated/jsp/j2ee-apps/<app_name>/<module_name>/<context_path>_SESSIONS.ser

where <app_name> is the name of your EAR-packaged application.

Many folks have wondered if it was possible to disable session persistence for their webapps, and the good news is: Yes, Glassfish makes this possible! All you need to do is specify a sessionFilename property with an empty value in your web application's sun-web.xml resource (located inside your web application's /WEB-INF directory), like this:


  <sun-web-app>
    <session-config>
      <session-manager>
        <manager-properties>
          <property name="sessionFilename" value="" />
        </manager-properties>
      </session-manager>
    </session-config>
  </sun-web-app>

The sessionFilename property may be used to customize the name of the file where persisted sessions are stored for your web application, and an empty value has the special semantics of disabling the persisting of memory-based sessions for your web application during a server restart.

Comments:

Is there a container-wide configuration option for this, so you don't have to edit the sun-web.xml of every webapp?

Posted by keccs on June 15, 2009 at 09:52 PM PDT #

Hi,

There is a container wide setting for this. Log on to server admin console, from left pane select: Configuration - Web Container

On right pane select Manager Properties, set Session File Name: value to: ""

Restart the server

Posted by Himanshu on August 20, 2009 at 12:14 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jluehe

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today