Can you hot deploy JAR files on Tomcat 5? The idea is to avoid restarting Tomcat and still be able to load (via reflection) some class from a newly added JAR. Can it be done
Yes, it is possible. A few tricks from the Tomcat stable, assuming that automatic deployment was switched on:
Of course, this is not advisable for production systems. Not that this feature is faulty, but applications can be poorly coded to not clean up resources or unload classes on undeployment. This will result in certain classes remaining in memory. When the newer version of the application is redeployed, you will encounter vague errors due to the older version of the classes being present. Poorly written singletons, are often the biggest cause of this issue.
The protocol that I follow, to avoid any similar issues is to undeploy the application, bring down Tomcat, verify the 'sanity' of the filesystem directories of Tomcat, delete any resources left behind, restart the Tomcat instance and redeploy the application. It does look a little heavy handed, but I've been burnt enough.