This is especially useful for reloading an application in a production environment, where Tomcat's automatic reload features should be disabled, or for low-performance environments where automatic reload could cause memory issues. The Tomcat Manager, a web application included with all standard distributions of Tomcat, has the ability reload web applications (as well as start, stop, deploy, and undeploy them), even if the application context is not configured as "reloadable". Restarting the Tomcat server is also a way to stop and restart your applications, which allows elements such as web.xml files to be reloaded (although there are ways of reloading these files without stopping the server).
These special cases include cases where your application has components that must be configured in Catalina's server.xml file, such as GlobalNamingResources, or if you have used a symbolic link to your docBase to configure application settings.
TOMCAT 8 NEW FEATURES FULL
Although this method is slow, and can be a real hassle if you are running multiple applications on your server, there are a number of situations where a full server restart is the most appropriate method of reloading your application. The most basic, free-of-error way to reload your web application is to restart your Tomcat server. This method creates a new classloader and new servlets, drops all references to the old servlets, and then calls the Servlet.init() method on the servlet, which brings the servlet to an initialized state, triggering a reload of all classes and libraries by the new classloader.īy contrast, "redeployment" means that the application is first deleted entirely from its deployed directory, and then re-deployed onto the server from your appBase directory. On an Apache Tomcat server, to "reload" an application means to call a method of the StandardContext class called StandardContext.reload() on a given Context. Although both have to do with propagating changes to an application to the server for use, these terms are not quite interchangeable. In this article, you'll see references to both "reloading" and "redeploying" web applications. How reloading worksīefore we begin, let's quickly define some of the terms used in this article, to avoid confusion.
We'll also cover some reasons why you should not use automatic reloading in a production environment, and some alternative solutions.