20050210 Thursday February 10, 2005

Context Reloading in Tomcat 5.5.7 Today I started using Tomcat 5.5.7 instead of 5.0.28. It was fairly easy to install on my PowerBook - I just had to add the xerces and jmx JARs from the compat package to get things working. The one thing I noticed that's different from Tomcat 5.0.28 is that when I deploy any file, it reloads the context. This can be a pain when I'm just copying JSPs into the webapps directory. I'm willing to admit it could be a problem with my "maven deploy" goal, but since this didn't happen on 5.0.28, I suspect it's the newer version of Tomcat. On 5.0.28, the context was only auto-reloaded when I updated files in the classpath.

The main reason this was frustrating is because we look up a bunch of data from a web service on app startup. The API we're talking to is nice and slow and it takes almost 50 seconds to start our application. Rather than go back to the older version of Tomcat, I wrote some code to serialize all the ServletContext variables to disk, and then check for that file on startup. If the file exists, it deserializes it and puts all the objects back in the ServletContext. Works pretty good and certainly speeds up my development environment. After all this, I'll probably downgrade to 5.0.28. Auto-reloading when classpath files change seems like a better way to go. Posted in Java at Feb 10 2005, 05:47:21 PM MST 5 Comments

Comments:

Have you looked in the file CATALINA_HOME/conf/context.xml? Im not sure if it will help your specific problem, but its handy to know about anyway. In it you can define what resources are watched and will trigger a reload of the context.

Posted by Daniel Campagnoli on February 10, 2005 at 06:34 PM MST #

Also, be aware that if you use Struts and its Plugin framework, your plugin destroy() method will not be called due to a bug in that version of Tomcat (fixed in CVS). I only mention it in case you also did any resource cleanup during context unloading.

Posted by Kev Palfreyman on February 11, 2005 at 03:21 AM MST #

Sorry if this might sound stupid :), but wasn't tomcat 5.5.x series developed for JDK1.5, and requires that runtime to run? This is in the readme. AFAIK there's still not MacOSX release of JDK1.5 , or am I missing something?

Posted by Ahmed Mohombe on February 11, 2005 at 03:45 AM MST #

5.5 can be set up to work with 1.4--Matt is mentioning the 'compat'-ibility package in his post. Matt, did you try to set reloadable="false" in the <Context> element for your app? My 5.5 upgrade adventure (on W2k adv. server) was fairly painless also, although I'm noticing my explorer windows are prone to crashing, esp. when I'm editing server.xml in notepad... Also, it appears that you can't have a root context defined to the folder you want, it HAS to be called ROOT... e.g. <Context path="" docBase="myAppFolder"> does not work. A blank page is all that comes back. Renaming the folder to ROOT made everything okay.

Posted by Patrick Dumontel on February 11, 2005 at 06:47 AM MST #

Hi Matt, Check out the Maven Tomcat plugin (http://www.codeczar.com/products/maven-tomcat-plugin/). If you set the reloadable attribute of your context to false (as Patrick mentioned) and add a post goal in maven on war:webapp to call tomcat:reload you should be right. Also, I find the war:inplace goal to be very useful when making JSP changes. Cheers, Dan

Posted by Dan Washusen on February 13, 2005 at 02:55 PM MST #

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is a Web Architect who enjoys developing applications with open source technologies. Contact me for rates.
« January 2009
SunMonTueWedThuFriSat
    
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Recent Entries

Tag Cloud