tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atanu Neogi <>
Subject Re: In-memory session replication without Clustering
Date Fri, 13 May 2005 19:09:41 GMT
        I am perfectly aware of everything you said. I have been working 
with Tomcat for last few years. I should have clarified that before.

I can do lot of these things using clusters and in-memory session 
replications. I was looking for some plug-in modules for Tomcat (and not 
external solutions like JBoss cache and Tangosol) to quickly implement 
cache sharing between web applications in a single Tomcat instance. I have 
one of my own based on persistent storage but that is not really 

Thanks anyway. 


"Will Hartung" <> 
05/13/2005 02:27 PM
Please respond to
"Tomcat Users List" <>

"Tomcat Users List" <>

Re: In-memory session replication without Clustering

> From: "Atanu Neogi" <>
> Sent: Friday, May 13, 2005 10:38 AM

> Hi,
>    a.    What is the best way to share a HttpSession between web
> applications running on a single Tomcat instance ? That Tomcat instance 
> not a cluster node and clustering has not been enabled.
>   b. What is the best way to share other java Object information 
> using common persistence storage ) in memory between web applications? 
> the add-on cache modules like JBoss cache etc. only solution?

The problem is that the webapps have their own distinct classloader
hierarchies, so that's one thing that makes sharing objects across webapps
difficult. Recall that an objects Class is based not just on the actual
Class it uses, but the Classloader for the class as well. Thus if you have
the an object of ClassX that's loaded by the classloader for WebappA, and
another object of ClassX loaded by WebappB, and in WebappA you try:

ClassX myObject = (ClassX)getObjectFromWebappB();

That will fail with a class cast exception, because WebappA.ClassX !=

Using a "clustering" style caching solution helps remedy this by 
the objects, which breaks a lot of those dependencies, but is obviously

One thing you can do, however, is move any classes that you want to share
across webapps out into the common/lib or common/classes directories. 
classes are all shared across webapps, so they can safely be used back and
forth between them, since they share the Common classloader.

As for sharing HttpSessions, I don't think you can do that directly, as 
webapp will have their own unique session. You'll need to have some other
means to identify the user outside of the sessionid (like, say, their 
name if they authenticate, or an arbitrary domain level cookie that you
create on the fly if it doesn't exist yet).

Then you use that credential to access shared information stored in a 
that's loaded from the Common classloader.


Will Hartung

To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message