servletshoststomcat9server.xml

Tomcat Configuration to host a webapp on different ports with different web.xml


I want to deploy my webapp with two different ports having two different deployment descriptors. Is there a way to do so? I know how can I deploy a webapp on multiple ports. Wonder if we can provide separate deployment descriptor for an app being deployed on each connector.

<Service name="serviceA">
    <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="10" 
               enableLookups="false" acceptCount="100"
               connectionTimeout="10000" disableUploadTimeout="true" 
               useBodyEncodingForURI="true"/>
    <Engine name="serviceA" defaultHost="localhost" jvmRoute="host1">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase" />
            <Host name="localhost" appBase="webapps" unpackWARs="true"
                  autoDeploy="false" xmlValidation="false"
                  xmlNamespaceAware="false" xmlBase="PATH_TO_CUSTOM_web.xml">
                    <Context docBase="browser" path="/browser" reloadable="false"/>
            </Host>
    </Engine>
</Service>
<Service name="serviceB">
    <Connector port="8081" maxHttpHeaderSize="8192" maxThreads="10" 
               enableLookups="false" acceptCount="100"
               connectionTimeout="10000" disableUploadTimeout="true" 
               useBodyEncodingForURI="true"/>
    <Engine name="serviceB" defaultHost="localhost" jvmRoute="host1">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase" />
            <Host name="localhost" appBase="webapps" unpackWARs="true"
                  autoDeploy="false" xmlValidation="false"
                  xmlNamespaceAware="false" xmlBase="PATH_TO_CUSTOM_web.xml">
                    <Context docBase="browser" path="/browser" reloadable="false"/>
            </Host>
    </Engine>
</Service>

Something like xmlBase="PATH_TO_CUSTOM_web.xml"


Solution

  • One can specify absolute path to the deployment descriptor instead of the default value.

    altDDName altDDName

    Ref: https://tomcat.apache.org/tomcat-8.5-doc/config/context.html