Hi Chuck,

thanks for this detailed answer. I'm running tomcat 6 on an ubuntu server. I read the official documentation and modified the configuration of my tomcat. The complete current server.xml (without comments and after my latest modification) looks like this:

server.xml:

<Server port="8005" shutdown="SHUTDOWN">


<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
 <Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

 <GlobalNamingResources>
   <Resource name="UserDatabase" auth="Container"
             type="org.apache.catalina.UserDatabase"
             description="User database that can be updated and saved"
             factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
             pathname="conf/tomcat-users.xml" />
 </GlobalNamingResources>

 <Service name="Catalina">

   <Connector port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443" />

   <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

   <Engine name="Catalina" defaultHost="localhost">
     <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
            resourceName="UserDatabase"/>

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

     <Host name="localhost.localdomain"
           debug="0"
           appBase="webapps2"
           unpackWARs="true"
           autoDeploy="true"
           xmlValidation="false"
           xmlNamespaceAware="false">
   <Alias>www.clubpirat.de</Alias>
     </Host>
   </Engine>
 </Service>
</Server>


I checked that in /etc/hosts the two domains "localhost" and "localhost.localdomain" are assigned to 127.0.0.1.

Now, i have the following directory structure:
CATALINA_HOME/webapps
CATALINA_HOME/webapps2
CATALINA_HOME/conf/Catalina/localhost
CATALINA_HOME/conf/Catalina/localhost.localdomain
CATALINA_HOME/webapps2/ROOT/META-INF

In "CATALINA_HOME/conf/Catalina/localhost.localdomain" i got the following files:
ROOT.xml  log4j_errors.log  manager.xml

And the latter ROOT.xml looks like this:
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="localhost.localdomain"
        workDir="work/Catalina/clubpirat.de/_">
</Context>

I also copied my war file into the CATALINA_HOME/webapps2 directory and tomcat has deploied the file.

Okay, i when enter the url www.clubpirat.de but i get an 404 error. The other url works fine, no problems.


Caldarale, Charles R schrieb:
From: Paul van Hoven [mailto:paul.van.ho...@googlemail.com]
Subject: Multiple Domains on one Tomcat Server now MySQL not working

I'm not shure if this problem really relates to Tomcat but it happened
after altering the tomcat configuration.

Care to give us a hint about version of Tomcat you're using?  Configuration is 
different from level to level.

Therefore i search on the internet how to manage
multiple domains on Tomcat.

Might be better to read the real documentation first:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html

I found this resource:
http://www.westsoftware.net/java/domains-on-tomcat.jsp.

It's unfortunate you found that, since it's chock full of errors.

     <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        </Host>
      <Host name="mydomain.de"
           debug="0"
           appBase="webapps/myapp2"

The above is not good; the different appBase directories must be distinct, not 
one under another.

           unpackWARs="true"
           autoDeploy="true"
           xmlValidation="false"
           xmlNamespaceAware="false">
    <Logger className="org.apache.catalina.logger.FileLogger"
           directory="logs"
           prefix="mydomain.de-log."
           suffix=".txt" timestamp="true"/>

<Logger> elements have not been used in Tomcat for some years.

    <Alias>www.mydomain.de</Alias>
      </Host>
    </Engine>
  </Service>
</Server>

and i added the follwing ROOT.xml file in the folder
$CATALINA_HOME/conf/Catalina/mydomain.de

ROOT.xml:
<?xml version='1.0' encoding='utf-8'?>
    <Context displayName="mydomain.de"
                  docBase=""
                  path=""
                  workDir="work/Catalina/mydomain.de/_">
</Context>

Both the docBase and path attributes have invalid values; luckily, neither one 
is allowed here, and they are hopefully being ignored.

Actually it works fine, i can now differentiate between the two webapps
by the domain.

What two webapps?  You have only shown us one <Context> element.

But while the first webapp has no problems accessing the
mysql database i do have problems with the second webapp for which i
added the new configuration.

What's the first webapp?  What <Resource> elements have you defined, and where are 
they?  You might want to post your complete server.xml and all <Context> elements.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to