0

Somehow I cannot normally map domain to my webapp in tomcat7.

Here is the parts from server.xml:

 <Engine name="Catalina" defaultHost="localhost">

 <Host name="mydomain.com" appBase="webapps" autoDeploy="true" unpackWARs="true">
        <Alias>www.mydomain.com</Alias>
        <Context path="" docBase="myapp"/>
                    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"
                    pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false" />
    </Host>

Does the defaultHost must be localhost or mydomain.com?

I have written a script which deploys myapp in ubuntu:

#!/bin/bash
service tomcat7 stop
rm -rf /usr/share/tomcat/webapps/myapp/
cp myapp.war /usr/share/tomcat/webapps/
service tomcat7 start

After running this script I can access my app only like this: mydomain.com/myapp

If I restart tomcat then it maps to the domain ok, but there is two webapps running.

What am I doing wrong?

1 Answer 1

0

To make your web application the default webapp you can simply

  • rename your myapp.war to ROOT.war,
  • rm -r /usr/share/tomcat/webappas/ROOT
  • cp ROOT.war /usr/share/tomcat/webapps

more information available at: http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F

2
  • Well this helps, but only because I have only one webapp.
    – sandris
    Feb 15, 2014 at 17:13
  • Well on production machines, I'm running one tomcat instance per webapp. This makes monitoring easier Feb 15, 2014 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.