Wednesday, April 13, 2011

How do I import the Host directive for Tomcat Server.xml from another file?

My company wants to be able to add other Hosts directives into our server.xml (configuration file for Tomcat). This Host directive goes inside the Engine directive. I will like to import a second file, example hosts.xml, so I can define the hosts in that separate files.

<Host name="localhost" ...>
 ...
<Valve className="org.apache.catalina.valves.AccessLogValve"
     prefix="localhost_access_log." suffix=".txt"
     pattern="common"/>
 ...
</Host>

I have looked into the Professional Apache Tomcat book by WROX ISBN: 0-7645-4372-5 and there was no answer there.

From stackoverflow
  • You do that by placing context xml files in the appropriate place:

    ${catalina.home}/conf/Catalina/www.example.com/ROOT.xml
    ${catalina.home}/conf/Catalina/www.foobar.com/ROOT.xml
    ${catalina.home}/conf/Catalina/www.foobar.com/other-webapp.xml
    Unfortunately your server.xml will still have to contain the root host elements:
    <Engine defaultHost="www.example.com" name="Catalina">
      <Host name="www.example.com"></Host>
      <Host name="www.foobar.com"></Host>
      ...
    
    Geo : none of these files exists.
    John Wagenleitner : You have to create the directories under conf/ as well as the context xml files. See http://tomcat.apache.org/tomcat-6.0-doc/config/host.html, sections "Automatic Application Deployment".

0 comments:

Post a Comment