Distributed sessions for multiple web-apps in a single App. Server (v.8.1)

I have 3 applications on App. Server 8.1 (running on JDK 1.5)

App-A handles login

App-B and App-C are functions that are accessible after login is validated.

It works fine with App. Server 6.5 (JDK 1.3)

But the distributed session cannot be shared in App. Server 8.1 (JDK 1.5)

So App-A handles sign on and stores the user's Login Name on the session.

App-B and App-C read the user's login name from the session object and grant access to different modules.

1. Starting App-A and perform login

2. Starting App-B from App-A (it is linked there)

3. Starting App-C from App-A (it is linked there)

In step 1, a new session is created for the user, an attribute ("LoginName") is put in the session - ie. using HttpSession.setAttribute()

In step 2, the program checks for attribute "LoginName" from the session object - ie. using HttpSession.getAttribute()

If not found, redirect to login; if found, then continue with App-B

In step 3, same as in step 2 above.

It works fine with App. Server 6.5 but problem occurs in step 2 and 3.

web.xml of App-A, App-B and App-C:

<i>

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>App-A</display-name>

<distributable/>

</i>

sun-web.xml of App-A, App-B and App-C

<i>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">

<sun-web-app>

<session-config>

<session-manager persistence-type="memory">

<manager-properties>

<property name="persistenceFrequency" value="web-method"/>

</manager-properties>

<store-properties>

<property name="persistenceScope" value="session"/>

</store-properties>

</session-manager>

</session-config>

</i>

[2257 byte] By [phui_doves] at [2007-11-26 8:41:55]
# 1

Distributed sessions has nothing to do with different web applications. The concept is about distributing load for the same application between several appserver instances running on the same box(different jvm) or on some other box in the network.

What you used with iAS 6.5 is not available in 8.1 because sharing sessions between web apps is forbidden by the servlet spec. You should consider repackaging your apps. into a single web app. or using other way of signing/verifying user identity(check Sun Access Manager for example).

Have a look at this thread as well: http://swforum.sun.com/jive/thread.jspa?threadID=100931

Sultal at 2007-7-6 22:20:41 > top of Java-index,Application & Integration Servers,Application Servers...
# 2

Thanks for your suggestion. Actually we managed to solve the problem by NOT setting login attributes to session. Instead we store them into cookies. Since we have many apps, we can't afford to repackage them into 1 war file. So the cookies solution is just a workaround. Thanks for your ideas.

phui_doves at 2007-7-6 22:20:41 > top of Java-index,Application & Integration Servers,Application Servers...
# 3
you can simply package several web-apps into a single ear.
handat_luc at 2007-7-6 22:20:41 > top of Java-index,Application & Integration Servers,Application Servers...