You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marc Dumontier <du...@mshri.on.ca> on 2003/03/04 22:32:26 UTC

reloading applications - classes stay in memory?

Hi,

I'm using the ant task to reload my web application during development. 
The problem is that I have a huge run time library (takes about 45 
seconds to load up the class itself). The static block is executed each 
time i reload (these are not servlets - they are JAXB generated 
classes). Is there any way to keep those classes loaded into tomcat, so 
when i reload the class is already initialized? is there an alternate 
method for accomplishing this?

thanks,
Marc Dumontier
Mount Sinai Hospital
Toronto, ON



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


Re: reloading applications - classes stay in memory?

Posted by Will Hartung <wi...@msoft.com>.
> From: "Marc Dumontier" <du...@mshri.on.ca>
> Sent: Tuesday, March 04, 2003 1:32 PM
> Subject: reloading applications - classes stay in memory?


> Hi,
>
> I'm using the ant task to reload my web application during development.
> The problem is that I have a huge run time library (takes about 45
> seconds to load up the class itself). The static block is executed each
> time i reload (these are not servlets - they are JAXB generated
> classes). Is there any way to keep those classes loaded into tomcat, so
> when i reload the class is already initialized? is there an alternate
> method for accomplishing this?

Place these classes outside of the WAR and into shared/classes or
shared/lib.

The problem is that when the app reloads, the classloaders for the app get
destroyed and recreated. A class within the JVM is actually the combination
of the class and its class loader.

If you place the classes outside of the WAR, then those class loaders will
not be reinitialized when the app is restarted.

Of course, should those classes change, you'll need to restart Tomcat.

Also, you should still, I feel, bundle those classes properly within the WAR
for deployment and production, but to expedite development, this should work
fine.

However there may be problems if it's using any reflection to load classes
that are also within the WAR, as the shared/* class loaders can not see any
classes within the WAR.

So, if your class shared.lib.TestClass does something like
Class.forName("in.the.war.TestClass"), it will fail.

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


Re: reloading applications - classes stay in memory?

Posted by Jacob Kjome <ho...@visi.com>.
Put those classes in one of the shared classloaders...

common/lib
common/classes
shared/lib
shared/classes

They will load once per server startup no matter how many times your apps 
are reloaded.

Jake

At 04:32 PM 3/4/2003 -0500, you wrote:
>Hi,
>
>I'm using the ant task to reload my web application during development. 
>The problem is that I have a huge run time library (takes about 45 seconds 
>to load up the class itself). The static block is executed each time i 
>reload (these are not servlets - they are JAXB generated classes). Is 
>there any way to keep those classes loaded into tomcat, so when i reload 
>the class is already initialized? is there an alternate method for 
>accomplishing this?
>
>thanks,
>Marc Dumontier
>Mount Sinai Hospital
>Toronto, ON
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org