tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <>
Subject Re: ClassLoader & Reloading issues: static values
Date Mon, 20 Aug 2001 11:44:43 GMT
On Mon, 20 Aug 2001, Miles Daffin wrote:

| This is an interesting one.
| I had assumed that statics were a nono in webapps
| because they broke Context encapsulation.

Easiest way to create e.g. Connection pools and the like.

| I declared a public static String in a Base servlet
| and built the host webapp twice, with two different
| values in this String into 2 war files with different
| names. After starting TC I could see that the same
| static String had different values in the 2 Contexts.

Why not, they're living in different classloaders..?

| I have just reread the 2.2 spec and do not recall seeing
| anything that suggested that compliant containers must
| behave like this. Did I miss something?

Probably something about ClassLoaders.. The two classes (instances of
them) are loaded with different ClassLoaders, and are therefore two
entirely different classes, try to for example to cast between them! (This
one was kind of hard to understand, I couldn't cast my object to the User
class, even if object.getClass().getName() returned User!!).


View raw message