Installation guide

Chapter 18. High-Availability Web Sessions
JBoss Enterprise Application Server allows you to make web sessions highly available by storing them
in a database table.
Session Replication Preferred
HTT P session replication with JBoss Cache is the preferred approach to securing web session
failover. It is strongly recommended to use this approach if possible (refer to Chapter 17, HTTP
session state replication).
To provide high availability web sessions, you can configure JBoss Application Server to store the web
session state in a database table. If the server then becomes unavailable, the web session state is still
preserved in the database table and can be used by failover servers, while if using session replication,
the web session is available on the server and the respective failover nodes. The high availability web
session setup can be useful in a WAN with several application server instance or in combination with
session replication.
To make web sessions highly available, you need to do the following:
configure the server to use the session manager set on your web application (JBoss Application
Server by default ignores the web application session manager and switches to
JBossCacheManager automatically);
configure your web applications to use DataSourcePersistentManager as their session manager (the
manager handles the storing of web sessions to the defined database table);
create the web session table in the target database and deploy the datasource, which will provide
the connection between the session manager and the database table.
Configuring JBoss Ent erprise Applicat ion Server
To configure JBoss Enterprise Application Server to allow storing of sessions in a database, disable
overriding of the session manager set on your web application (overriden to JBossCacheManager; this
allows the web application to use its own session manager):
1. Open the JBOSS_HOME/server/PROFILE/deployers/jbossweb.deployer/META-INF/war-
deployers-jboss-beans.xml file for editing.
2. Set the overrideDistributableManager property of the WarDeployer bean to false:
<bean name="WarDeployer"
class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">
. . .
<!-- "False" disables overriding the session manager for distributable
webapps -->
<property name="overrideDistributableManager">false</property>
</bean>
Configuring Web Application
Configure your web application to use the database persistent session manager:
1. In the application's WEB-INF directory, create the context.xml file, which will define what session
manager is to be used as well as the manager's attributes.
Important
Note that it is not recommended to add the manager definition to the jboss-web.xml file,
although it is the standard web application deployment descriptor. T he goal of using the
context.xml file instead is to avoid any unnecessary changes to the existing JBoss
Application Server code.
2. In the context.xml file, add the Manager element and its attributes:
cla ssName
fully-qualified class name of the session manager implementation
dataSourceJndiName
datasource that allows the session manager to communicate with the database that
stores the web sessions
72 Chapter 18. High-Availability Web Sessions