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.xml
?
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.xml
?
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.Gathering information from the startup process and the class-loader pages on Tomcat's online documentation, it is possible to understand this in more detail.
More specifically, it's described in serverStartup.txt and the UML diagram of the startup process and the relevant portions can be summarized as follows:
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.Connect you
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):
No. Restart Required.
The Tomcat doc page for
<Context>
mentions: