tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atanu Neogi <Atanu_Ne...@symantec.com>
Subject Re: In-memory session replication without Clustering
Date Fri, 13 May 2005 19:09:41 GMT
Will,
        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 
efficient. 

Thanks anyway. 

Regards.




"Will Hartung" <willh@msoft.com> 
05/13/2005 02:27 PM
Please respond to
"Tomcat Users List" <tomcat-user@jakarta.apache.org>


To
"Tomcat Users List" <tomcat-user@jakarta.apache.org>
cc

Subject
Re: In-memory session replication without Clustering






> From: "Atanu Neogi" <Atanu_Neogi@symantec.com>
> 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 
is
> not a cluster node and clustering has not been enabled.
>
>   b. What is the best way to share other java Object information 
(without
> using common persistence storage ) in memory between web applications? 
Are
> 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 !=
WebappB.ClassX.

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

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. 
Those
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 
each
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 
login
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 
Cache
that's loaded from the Common classloader.

Regards,

Will Hartung
(willh@msoft.com)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



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