tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Molloy" <>
Subject RE: reloading..
Date Tue, 28 Nov 2000 14:20:29 GMT

	I have something similar in place but it's working pretty much.
Set up one web application area with all your database classes,
ConnectionPool etc.  Make this area non-class reloadable and put
a load-on-startup on the pool.  Now assuming you make static references
to the ConnectionPool then you can reference it from other web
applications.  All the while you can develop in these applications
with class reloading enabled (as you are not directly affecting
your connection pool anymore) and it should work....

I was very happy when I got this all working but as it happens I still
need to restart Tomcat after I make changes.  You'll find if you use
sessions to store classes (in my case I store the User class in a
session variable called theUser) there seems to be a problem with
reloading.  If anyone has anything to add to this I'd be grateful
but I'd asked it before.  Seemingly when you cause a class reload
the classes reload but the sessions don't invalidate - so when you
do a req.getSession(true) you'll find that it grabs the old one and
when you try to grab theUser it will give a ClassCastException.
As another person commented before - it seems like a feature but
it's more like a bug.


-----Original Message-----
From: Alistair Hopkins []
Sent: Monday, November 27, 2000 4:58 PM
Subject: RE: reloading..

give up, restart tomcat.

i found that to be the only sureproof way :-(

-----Original Message-----
From: Endre StĂžlsvik []
Sent: Monday, November 27, 2000 4:49 PM
Subject: reloading..

I'm going a bit crazy soon, so any help here would be much appreciated!

I have a DB pool. I instantiate this class as a "connection holder", and
the pool is a static field in this class. I also have a static int that I
increase each time I make a new of these connection holders, and decrease
each time they get garbage collected.
  I Initialize this from a servlet ( that I've defined as
"load-on-startup". This goes just fine, and everything is merry.

When I recompile my servlets, beans and helpers (rm all .class files, and
jikes the whole thing), I apparently have "lost" this pool somewhere. I
get a nullpointer exception at the point where I try to reference it. The
counter I was talking about has also been reset to zero.

I then tried to put a call to the initialization in the "doGet()" of the, so that I can call it when I need it. This is when things
get annyoing.
  I now (sometimes!) apparently get two different "contexts" of servlets.
This because the call to and this other servlet gives me
_different_ values from this counter. So the is happy,
because the pool is working fine there, but my main servlet hasn't got the
same class or whatever.

As I've understood it, this is because I now have two different
classloaders loading these classes, and in reality, two enirely different
contexts. Is this really the way it's meant to be, or am I totally doing
something wrong?

Is there _anything_ I can do from within the servlets to just get rid of
ALL classes and start all over if tomcat notices a "reload-situation"? If
I have to go to the tomcat source, where should I start?!

Any help would much appreciated.


View raw message