Skip to main content

keepstate, keepSessions, keep-state, save-sessions-enabled in GlassFish 3.1

Posted by swchan2 on March 9, 2011 at 6:34 AM PST

GlassFish supports the preseving of HTTP session data across the redeployment of web application.

Prior to GlassFish 3.1, one can achieve this through the command line as follows:
  asadmin redeploy --properties keepSessions=true --name ${APP_NAME} ${A_WAR}

In GlassFish 3.1, web sessions, Stateful Session EJB instances and persistently created EJB timers can be retained between redeployments. A new option is introduced as follows:
  asadmin redeploy --keepstate=true --name ${APP_NAME} ${A_WAR}

In addition, one also supports the preseving of HTTP session data through the deployment descriptor in glassfish-web.xml as follows:

<glassfish-web-app>
  <keep-state>true<keep-state>
<glassfish-web-app>

As an alternative, one can use weblogic.xml as follows:

<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
  <container-descriptor>
    <save-sessions-enabled>true<save-sessions-enabled>
  <container-descriptor>
<weblogic-web-app>

In this case, the command options override the deployment descriptor. And as usual one will ignore the presence of weblogic.xml if there is a glassfish-web.xml. Hence, for HTTP session data, we have the following precedence:

       --keepstate >     --properties keepSessions >     <keep-state> >     <save-sessions-enabled>