I edited the "server.xml" file in Tomcat 8’s
conf folder. I added a new
Host tag for a new web site.
Must I restart the Tomcat server?
Can I get Tomcat to parse and apply the newly edited
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
I'd start by saying that the question is not completely correctly made, as it is quite possible to actually edit the file without restarting Tomcat, but the changes are ignored by the running process.
The real question would be how to apply changes in
server.xml without restarting Tomcat.
Sequence 1. Start from Command Line ... Sequence 2. Process command line argument (start, startd, stop, stopd) Class: org.apache.catalina.startup.Bootstrap (assume command->start) What it does: a) Catalina.setAwait(true); b) Catalina.load() b3) createStartDigester() Configures a digester for the main server.xml elements b4) Load the server.xml and parse it using the digester Parsing the server.xml using the digester is an automatic XML-object mapping tool, that will create the objects defined in server.xml Startup of the actual container has not started yet. b6) Calls initialize on all components, this makes each object register itself with the JMX agent.
This happens after the creation of the Bootstrap classloader of the servlet engine (Catalina).
With this information, it's clear now when in the startup process the
server.xml file is parsed, but it doesn't really answer the question of why it is required to restart Tomcat to apply changes to this file.
The answer is that some part of it can be modified dynamically at runtime using JMX. For this to be possible, the appropriate MBean has had to be registered (b6 step above), and also has to accept SET operations (some MBeans only have a GET interface).
In your specific case, there is no way to create and register a new Host at runtime because there's no provision for it, and this is the reason why you have to restart the Tomcat process to have the Bootstrap classloader instantiate that object and register it with JMX agent.
Afterwards, it is possible to modify that host from a JMX client such as the
jconsole that comes bundled with any JDK.
jconsole to an JMX enabled Tomcat and browse the Host MBean to check all available attributes:
and check all the available operations (one of them shown below as an example):
The Tomcat doc page for
…the main conf/server.xml file cannot be reloaded without restarting Tomcat.