This is a quick TIP for anyone working with Tomcat during development and needing it to reload changes immediately… especially if you have Tomcat setup to run your webapp directly out of your IDE’s project folder.
REMINDER: Remember you have to change your Project Properties to make your [projdir]/[webdir]/WEB-INF/classes directory your output dir for built classes. By default Eclipse wants to put them in [projdir]/build/classes and Tomcat can’t see them.
For example, I had a custom <context> setup to load my web app directly from my Eclipse project:
<Context reloadable="true" antiResourceLocking="true" docBase="path-to-workspace\api.imgscalr.com\webroot" />
Unfortunately, every time I changed a class in Eclipse and hit save, Tomcat 7 wasn’t seeing the changes and reloading the web context.
TIP: You can work around this by setting up Eclipse’s remote debugger to connect to Tomcat; then as long as the “shape” of your class doesn’t change during editing, the VM will swap the class immediately instead of reloading the context.
I started to play around with the different settings (moving the context to the root path and into server.xml) and couldn’t get it working.
Then I read in the Tomcat context doc page that setting antiResourceLocking to true disables the ability of Tomcat to reload changes to JSPs, so I figured that might be it.
I swapped antiResourceLocking with the more-specific antiJARLocking setting and suddenly Tomcat was detecting and reloading my changes!
<Context reloadable="true" antiJARLocking="true" docBase="path-to-workspace\api.imgscalr.com\webroot" />
Hope this helps anyone else stuck on this.