How to make your web application the Tomcat default application


One would say you have to change your application’s war file name to ROOT.war. But this is not the best thing to do.

Following the instructions of the Tomcat Wiki and reading about Host and Content elements in server.xml, I came to the following elegant solution:

<Host name="localhost" appBase="webapps"
 unpackWARs="true" autoDeploy="false" deployOnStartup="false"
 xmlValidation="false" xmlNamespaceAware="false">

          <Context docBase="C:\\Documents and Settings\\mfernandes\\Documents\\workspace-sts-2.9.0.RELEASE\\xilya\\target\\xilya-0.1.war" debug="0" crossContext="true" path="">
               <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
          </Context>

          <Context docBase="C:\\apache-solr-3.5.0\\example\\solr\\solr.war" debug="0" crossContext="true" path="/solr">
<Environment name="solr/home" type="java.lang.String" value="C:\\apache-solr-3.5.0\\example\\multicore" override="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
          </Context>
</Host>

<strong>

As you can see in this real example I have an war file of an Grails application and a Solr war file. While the former has the attribute path=”” which means it is the default application, the latter will be accessed by a /solr URL.

Deixe uma resposta

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair / Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair / Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair / Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair / Alterar )

Conectando a %s