[prev in list] [next in list] [prev in thread] [next in thread]
List: tomcat-user
Subject: Sharing an object between two webapps
From: Kaspar Fischer <fischerk () inf ! ethz ! ch>
Date: 2007-11-23 16:07:31
Message-ID: 0EFBD37E-AAB0-4EE3-B4BC-80AF1C0D6330 () inf ! ethz ! ch
[Download RAW message or body]
Hi everybody,
I need to share an object between two webapps A and B. How can I
accomplish this?
My first webapp, A, has a class SharedObjectHolder with a static
public member:
public class SharedObjectHolder {
public static Object objectToShare;
public void setObjectToShare(Object objectToShare)
{
SharedObjectHolder.objectToShare = objectToShare;
}
}
and my webbapp A calls setObjectToShare(...). After this, webapp B does
System.err.println(SharedObjectHolder.objectToShare);
and this is null. The same statement in webapp A returns something
nonnull.
Looking at http://www.nabble.com/Object-sharing-tf1652024.html#a4475590,
it seems that two instances of SharedObjectHolder exist. Is this
correct?
How can I tell Tomcat to not create two instances but use the same from
both webapp A and webapp B?
I guess this is related to classloaders, but do not know how to proceed.
Thank you very much for any hint!
Kaspar
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic