On Sun, 11 Mar 2001, Peter Adamek wrote:

[ ... ]
> The contexts name is /dev and works when placed in
> $TOMCAT_HOME/webapps/dev, but does not work when created under
> /home/www/webapps/dev.  /home/www is my document root directory from
> which Apache serves pages so if I type www.mydomain.com/webapps/dev,
> I should reach my context without needing any alias or link to it.

You may reach your context that way, but it is apache reaching it, not
tomcat, and, unless told otherwise, it's nothing special to apache,
just another directory.

> Here is the porstion of the server.xml file that defines the new
> context in a new webapps directory I created in my web path
> /home/www.  This is the one that didn't work.
> 
>        <Context path="/dev"
>                  docBase="/home/www/webapps/dev"
>                  crossContext="false"
>                  debug="0"
>                  reloadable="true" >
>         </Context>
> 
> Here is a portion of the tomcat.conf file that pertains to the above
> context that won't serve servlets.
> 
> <Directory "/home/www/webapps/dev">
>     Options Indexes FollowSymLinks
> </Directory>
> <Location "/dev/WEB-INF/">
>     AllowOverride None
>     deny from all
> </Location>
> <Location "/dev/META-INF/">
>     AllowOverride None
>     deny from all
> </Location>
> 
> ApJServMount default /root
> ApJServMount /servlet /ROOT
> ApJServMount /examples/servlet /examples
> ApJServMount /dev/servlet /dev
> 
> The only change I made is added one line to my tomcat.conf file
> which is to alias the /home/www/webapps/dev directory to /dev using
> the follwing directive:
> Alias /dev "/home/www/webapps/dev"

Well, that's good :-), because that's what I was going to suggest you
try.  At least, it was the thing I noticed missing from your setup as
compared to mine (which I basically copied from the sample provided).


[ ... ]
> This started to work but WHY?  Keep in mind that my apache web
> server has its DocumentRoot set in /usr/www so why on earth do I
> have to alias /usr/www/webapps/dev to /dev in order to get tomcat to

(I assume you meant "/home/..." instead of "/usr/..." in both those
cases, otherwise it doesn't match what you said earlier.)

> work.  I can get to this directory from my base domain by typing
> www.mydomain.com/weapps/dev so why do I need the alias?

I guess I'm a little confused as to the exact need for the Alias as
well.  At first, I'd say it has something to do with letting apache
know where the context is located.  But if you tell apache to pass
URI's beginning with "/dev" (or "/dev/servlet") to tomcat (by virtue
of the ApJServMount directives), and tomcat knows where the "/dev"
context is (by virtue of the Context tag in server.xml), what does the
Alias add?

I guess it has something to do with the fact that that directory is
not directly under the DocumentRoot, and perhaps it goes along with
the Directory tag (which, it looks like, uses physical directories, as
opposed to Location, which uses virtual ones).

Also, I think the fact that you can get to this directory via
www.mydomain.com/weapps/dev is a bit of a red herring -- as I said
earlier, if you do that, you're getting there as apache, not tomcat,
and to apache it's nothing special, just a directory.


> OH here is another interesting thing.  Since typing in
> www.mydomain.com/dev and www.mydomain.com/webapps/dev get me to the
> same physical poing in my directories I should get the same result,
> RIGHT?  WRONG!  The former serves servlets while the latter gives me
> 404 ERRORS?!?!?

I don't think you should get the same result -- this is related to my
comment above about getting there as apache vs. getting there as
tomcat.  If you get there as tomcat (as is the case when you use
www.mydomain.com/dev), tomcat finds servlets and knows what to do with
them; but if you get there as apache (as is the case when you useN
www.mydomain.com/webapps/dev), it only sees it as another directory to
serve.  Now, I'm not sure why you're getting 404 errors, since that
directory is there (unless you're not showing the full URL you are
using, and it's got a trailing "/servlet/...", or something similar,
on it).


> Beyond that , according to the above setup in tomcat.conf (which I
> include in my httpd.conf file), I should not have access to my
> WEB-INF and META-INF directories.  Well why is it that if I go to
> www.mydomain.com/dev/WEB-INF I am not given access, but if I type
> www.mydomain.com/webapps/dev/WEB-INF, I am given access (I get this
> even if I remove the above alias and put in the full paths to
> /dev/WEB-INF).

This behavior makes sense to me, as per what I've mentioned above.
You've put restrictions on the (virtual) location /dev/WEB-INF, but
not on the (physical) directory /webapps/dev/WEB-INF.

Actually, this kind of thing is why I think it's a bad idea to have
your webapps under your DocumentRoot, and I'd suggest placing them in
a totally separate directory hierarchy.


> Please help, how can I tell tomcat that the /dev direcotry and
> context within my /home/www/webapp directory should be treated like
> a context and not left for Apache to serve as a static directory.
> Is there a way I can get this witout using an alias?
> 
> Maybe I am not supposed to have contexts directly accessible from my
> Document Root directory.  This is a possibility and I may not even
> know it.  If so, please let me know.

I don't think it's a matter of you're not being "supposed to", more
just that there may some cons to doing it that way.  For example, you
may have to add appropriate Directory/Location tags to protect access
to them as documents from apache.  On the other hand, if you have no
particular reason for doing it this way, you might be able to avoid a
lot of problems simply by moving the webapps to a different directory
hierarchy.  As to having to use an Alias, what's so bad about that?

Well, I don't think I really definitively addresses these issues, but
maybe it will act as some food for thought.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]


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

Reply via email to