Hi Scott,

Scott Purcell wrote:
I am completely lost in trying to configure my Tomcat 5.5. I have read the docs under "Context", 
"Engine", "Host", and am having trouble putting the information to use.

I have one webapp that I need to configure to a DNS Entry.

I believe the technical term for this is a "root" web application.

Below is my server.xml. My DNS is www.theuniquepear.com and it lives under 
webapps/unique. But with the below configuration, and when I try and hit the 
url it goes here:
http://www.theuniquepear.com/ and does not go to the context of "unique"?

AFAIK, web apps put in the ${TOMCAT_HOME}/webapps folder are always "context" web applications, IOW they will always have a url like www.my_dns.com/my_context. You'll probably find that if you type in http://www.theuniquepear.com/unique your app will come up, but of course this isn't what you want.

Can anyone assist me here?

The way I achieve what you're trying to do is to create virtual hosts in my servlet.xml file and point them at a directory structure outside the Tomcat tree altogether.

In our setup, we have a /data/www folder and each web app lives under that. In Tomcat 5.5, there's a "gotcha" for "root" web applications, they must live in a folder named "ROOT".

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

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <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="80" />

    <!-- This is here for compatibility only, not required -->
    <Connector port="8009" protocol="AJP/1.3" />

<Engine name="Standalone" defaultHost="localhost" debug="0">
      <!-- This Host is the default Host -->
      <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true">
        <Context path="" docBase="ROOT" debug="0"/>
        <Context path="/orders" docBase="/home/ian/orders" debug="0"
                       reloadable="true" crossContext="true">
        </Context>
      </Host>
<snip>
      <!-- This Host is the first "Virtual Host": www.example.com -->
      <Host name="www.theuniquepear.com" appBase="webapps/unique">
        <Context path="unique" docBase="."/>
      </Host>
</snip>
OK, in our setup, I'd change the above to:

       <Host name="www.theuniquepear.com" appBase="/data/wwww/unique">
       </Host>

Lose the <Context ..> tag - I believe that recent versions of Tomcat ignore any <Context ..> tags in server.xml


    </Engine>

</Service>
</Server>

Now, to finish off, in the /data/www/unique folder, create a folder named ROOT (ie /data/www/unique/ROOT - note it must be uppercase) and put your web app in that.

Provided you're not doing anything too complex (ie your "welcome file" is index.jsp or index.html etc), that should just work by itself.

If you need to include a <Context > tag for your application, create a file called "context.xml", put your context info in that and place it in a directory called META-INF in your web app (ie /data/www/unique/ROOT/META-INF ). If you need a web.xml file, of course that goes in /data/www/unique/ROOT/WEB-INF.

I have a number of "root" tomcat applications up and running now (eg http://www.netpaver.com.au, http://aroundaustraliachallenge.org ) and it's taken me a while to figure it all out, so if you have any other queries or problems with this, give me a shout.

Cheers,

Rob Hills
NetPaver Pty Ltd
Western Australia


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to