Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes Automatically Reloading Servlets in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Automatically Reloading Servlets in tomcat" Watch "Automatically Reloading Servlets in tomcat" New topic

Automatically Reloading Servlets in tomcat

Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64
Hello All,

I am a learner.I want my tomcat 4.1 to automatically reload my servlet class when it was changed.

This is my server.xml file contents line for my appl

<Context path="/app" docBase="e:/progra~1/Tomcat_app/webapps/app1" debug="0"
reloadable="true" crossContext="true">

Later I also added DefaultContext element to host element.

<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<DefaultContext reloadable="true"/>

When i do changes to my servlet and do compilation,replace the files,the tomcat is not taking the changes.When i restart the tomcat, then the changes were working fine.

Pl tell me what was the problem or show me the correct way to do it.


The value of an idea lies in the usage of it.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Personally I use the Tomcat Management Application - it lets you unload and reload a specific web application. According to the specs, reloadable="true" should work by monitoring the timestamps on the .class and .jar files - I dunno why it doesn't in some installations.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63839

There are some known problems in Tomcat 4 (specifically with 4.1.27 if I recall) with reloading. Tomcat 5 seems to have solved these issues (and I believe there is a patch for 4.1.27 but I can't vouch for it).

[Asking smart questions] [About Bear] [Books by Bear]
Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64

I will try with the Tomcat Manager Application.How to configure for that.

Later,I will do my appl in tomcat 5.

Thanks a lot.
I agree. Here's the link:
subject: Automatically Reloading Servlets in tomcat
It's not a secret anymore!