On 1/30/2014 5:33 PM, Jerry Malcolm wrote:
well I thought I had it down. but now things aren't working.
I have a directory structure: c:\domains\myhost\webapps\aWebApp\....
In server.xml, I've defined the host with appRoot of c:\domains\myhost\webapps
I want the url to this webapp to be myHost.com/aaa
So according to the instructions above, I created a context file:
.....\conf\Catalina\myHost\aaa.xml (using the url context path)
In the file aaa.xml I defined the context with path="/aaa" and
docBase="aWebApp"
Do NOT define a path. It is taken from the name of the xml file.
When I start TC, I first get this error in the catalina log:
WARNING: A docBase c:\domains\myHost\webapps\aWebApp inside the host
appBase has been specified, and will be ignored
followed by an error saying ".....myHost\webapps\aaa can't be found or
is not a readable directory".
Well it definitely makes sense that if it's going to ignore the
docBase specification, it isn't going to find the right directory.
What am I doing wrong?
Thx.
Jerry,
A. docBase versus appBase
From the documentation at
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html:
===============================
docBase
The Document Base (also known as the Context Root) directory for this
web application, or the pathname to the web application archive file (if
this web application is being executed directly from the WAR file). You
may specify an absolute pathname for this directory or WAR file, or a
pathname that is relative to the appBase directory of the owning Host.
The value of this field must not be set unless the Context element is
defined in server.xml or the docBase is not located under the Host's
appBase.
================================
Let's parse that a bit:
The docBase is relative to the appBase of the owning host.
So in server.xml, if you have a host element like the following:
<Host name="myHost.com" appBase="c:\domains\myHost\webapps"
unpackWARs="true" autoDeploy="true">
</Host>
And you have a docBase in your aaa.xml file that looks like the following:
<Context docBase="aWebApp">
</Context>
Then Tomcat is going to look for the application in:
c:\domains\myHost\webapps\aWebApp
And this, according to the documentation that I quoted above is not legal.
Don't do this.
B. path attribute
From the documentation at
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html:
===============================
path
The context path of this web application, which is matched against the
beginning of each request URI to select the appropriate web application
for processing. All of the context paths within a particular Host must
be unique. If you specify a context path of an empty string (""), you
are defining the default web application for this Host, which will
process all requests not assigned to other Contexts.
This attribute must only be used when statically defining a Context in
server.xml. In all other circumstances, the path will be inferred from
the filenames used for either the .xml context file or the docBase.
Even when statically defining a Context in server.xml, this attribute
must not be set unless either the docBase is not located under the
Host's appBase or both deployOnStartup and autoDeploy are false. If this
rule is not followed, double deployment is likely to result.
===============================
Let's parse that a bit:
In short it says the following:
Do NOT define a path element unless the following statements are true.
1. Context element is in server.xml
2. One of the following:
a. the docBase is NOT in the Host's appBase (see above)
or
b. both deployOnStartup and autoDeploy are false (not the default)
In all other cases the path is inferred from either the
conf\Catalina\[hostname]\appName.xml file or the WAR file name or the
directory name in appBase.
Please also note that ROOT is the special name (case is important, even
on Windows) reserved for the default web application for the enclosing Host.
You can do this several ways.
1. ROOT.war or the directory ROOT in appBase
2. ROOT.xml in conf\Catalina\[hostname]
a. no path element
b. docBase to application MUST be outside of the Host's appBase
3. Context in server.xml
a. strongly discouraged
b. several restrictions
i. docBase MUST be outside of the Host's appBase
or
ii. both deployOnStartup and autoDeploy are false (not the
default)
c. Then you can define a path=""
That's it.
================================
I have written a Wiki article on how to set up virtual hosts using
Tomcat. It is available here:
http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts
While it is a bit dated and references a development environment, the
same structure is valid today. We run a variant of the structure
documented in that wiki article in production and it works well.
/mde/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org