tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Adamek" <peter_ada...@hotmail.com>
Subject Re: Context not working when not in $TOMCAT_HOME/webapps
Date Thu, 01 Jan 1970 00:00:00 GMT
OK, I think I fixed my problem, but I am not sure why this is:

Here is the background on the problem.  I have a linux machine (RH7)
running Apache and Tomcat.  All seems to be running well.  I was able to 
create my own context under the $TOMCAT_HOME/webapp directory and it serves 
jsp's and servlets, but when I try and create a context outside of this 
webapp directory (i.e. in my web path), I can't seem to get the servlets to 
run.  I just get a 404 error from Netscape.  If I just move the context 
under the webapps directory, it seems to be running fine.

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.

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"

So now the whole thing reads as follows (this is an excerpt from my
tomcat.conf file that concerns the setting up of a new context not in
the $TOMCAT_HOME/webapp directory):

Alias /dev "/home/www/webapps/dev"
<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>

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 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?

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?!?!?

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).

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.

Thanks in advance!

Peter

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message