On 25 Nov 2001, Kevin A. Burton wrote:

> Date: 25 Nov 2001 21:20:09 -0800
> From: Kevin A. Burton <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: 4.0.1 ClassLoader breaks singletons on webapp reload.
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> OK.
>
> I have a webapp deployed with the main package under WEB-INF/classes and all
> dependent libraries under WEB-INF/lib as .jars.
>
> If I recompile my application, update the necessary classes in WEB-INF/classes,
> Tomcat does manage to reload the app but my application is now totally hosed.
>
> The reason is that Tomcat didn't just reload the changed classes but it reloaded
> everything including the all classes under WEB-INF/
>
> Is there anyway I can tell Tomcat to JUST reload the changed classes and not
> the whole webapp?
>

With current (JDK 1.3) JVMs, this is not possible.

> The problem is that any singletons I have (which depended on correct
> initialization) are now broken and I have lost all state.
>
> I remember talking to Craig about ClassLoaders a while back and he mentioned
> that the JVM has now way for a ClassLoader to unload a class so they have to
> start out with a new ClassLoader.
>
> Is there any way around this?
>

There is some support for replacing existing classes in 1.4-based JVMs,
but I've never tried any of this.  The current architecture ("reload
everything") is fundamentally driven by JVM restrictions, not Tomcat
restrictions.

To deal with singletons, you should investigate implementing an Event
Listener that listens to contextStarted() and contextDestroyed() events.
The application can easily insure that static references across server
restarts work as expected, using this technique/.

> - --
> Kevin A. Burton ( [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] )
>              Location - San Francisco, CA, Cell - 415.595.9965
>         Jabber - [EMAIL PROTECTED],  Web - http://relativity.yi.org/
>
> If you play with fire, you might get burned.  If you eliminate fire, you will
> never feel it's warmth and never enjoy it's illumination.


Craig


>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt
>
> iD8DBQE8AdDnAwM6xb2dfE0RAr8QAKDFZcH/4x//zruXH4TmLxrKTlj07ACfXgGI
> SKo5PJqFrUGplf8Ah6NFMyE=
> =hvTp
> -----END PGP SIGNATURE-----
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to