You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by arnaud icard <ar...@univ-avignon.fr> on 2010/10/07 11:49:29 UTC
Error 404 when redirected
Hello,
I am currently installing and configuring a webserver with the couple
httpd/tomcat.
This server hosts many tomcat applications, each one with its own hostname.
My current Tomcat configuration is something like that :
<Host name="appli1.domain.fr" appBase="/var/www/appli1"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="/var/www/appli1" crossContext="false">
...
<Host name="appli2.domain.fr" appBase="/var/www/appli2"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="/var/www/appli2" crossContext="false">
...
The httpd VHost configuration is:
<VirtualHost *:80>
ServerName appli1.domain.fr
ProxyPass / ajp://appli1.domain.fr:8009/ retry=1
...
<VirtualHost *:80>
ServerName appli2.domain.fr
ProxyPass / ajp://appli2.domain.fr:8009/ retry=1
...
It's working for every applications except the appli2.
The appli2 interprets the index.jsp which redirects to
http://appli2.domain.fr/stylesheets/welcome.faces.
At this point I have a 404 error : /The requested resource
(/stylesheets/cas.faces) is not available./
How could it interprets the index.jsp but then cannot find the
/stylesheets/welcome.faces ?
Does it come from my configuration or may it come from the application ?
I have tried a different Tomcat configuration :
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/var/www/appli2" crossContext="false">
...
Then the apache2 vhost :
<VirtualHost *:80>
ServerName appli2.domain.fr
ProxyPass / ajp://localhost:8009/ retry=1
...
This one works fine but I would like to understand where does the
problem comes from.
Regards,
arnaud
Re: Error 404 when redirected
Posted by arnaud icard <ar...@univ-avignon.fr>.
Thank you for these explanations Chuck!
Caldarale, Charles R a écrit le 07/10/2010 15:38:
>> From: arnaud icard [mailto:arnaud.icard@univ-avignon.fr]
>> Subject: Re: Error 404 when redirected
>>
>
>>> Second, you should not be placing<Context> elements in server.xml.
>>>
>> This is not completly true
>>
> Note that I said "should not" rather than "must not". You can place<Context> elements in server.xml, but it is not best practice, and is strongly discouraged. Don't do it.
>
>
>>> Third, each<Host> should have a unique appBase directory.
>>>
>> This is already the case, isn't it?
>>
> Not really, since docBase == appBase in your original config. Your original configuration was ambiguous.
>
>
>> Most of these applications are deployed using ant deploy.
>>
> Not relevant.
>
>
>> Thus I cannot place context file in the application/ROOT/META-INF
>>
> Of course you can. However, as I stated earlier, you don't actually need any<Context> elements in the examples you gave.
>
>
>> So I now have the following server.xml :
>> <Context path="" docBase="ROOT" crossContext="false">
>>
> Just remove the<Context> elements like the above - they're unnecessary.
>
>
>> <Context path="" docBase="uportal" crossContext="false">
>>
> Remove that one as well, and change the uportal directory name to ROOT.
>
>
>> <Context path="/ResourceServingWebapp" docBase="ResourceServingWebapp" crossContext="false">
>>
> That<Context> element is also not necessary - remove it.
>
>
>> The file layout for uportal is (yes 2 times uportal):
>> /var/www/uportal/
>> uportal/
>>
> Change the above to ROOT/.
>
>
>> ResourceServingWebapp/
>>
> That one is fine.
>
>
>> I don't get why I had to specify ROOT in the docBase argument.
>>
> You shouldn't have a docBase argument, because you don't need any<Context> elements at all.
>
>
>> Is it not the value by default ?
>>
> No; there is no default for docBase, since it should be used only when a<Context> element is in conf/Catalina/[host]/[appName].xml, and the associated webapp is located outside of the<Host>'s appBase directory.
>
> - 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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
RE: Error 404 when redirected
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: arnaud icard [mailto:arnaud.icard@univ-avignon.fr]
> Subject: Re: Error 404 when redirected
> > Second, you should not be placing <Context> elements in server.xml.
> This is not completly true
Note that I said "should not" rather than "must not". You can place <Context> elements in server.xml, but it is not best practice, and is strongly discouraged. Don't do it.
> > Third, each <Host> should have a unique appBase directory.
> This is already the case, isn't it?
Not really, since docBase == appBase in your original config. Your original configuration was ambiguous.
> Most of these applications are deployed using ant deploy.
Not relevant.
> Thus I cannot place context file in the application/ROOT/META-INF
Of course you can. However, as I stated earlier, you don't actually need any <Context> elements in the examples you gave.
> So I now have the following server.xml :
> <Context path="" docBase="ROOT" crossContext="false">
Just remove the <Context> elements like the above - they're unnecessary.
> <Context path="" docBase="uportal" crossContext="false">
Remove that one as well, and change the uportal directory name to ROOT.
> <Context path="/ResourceServingWebapp" docBase="ResourceServingWebapp" crossContext="false">
That <Context> element is also not necessary - remove it.
> The file layout for uportal is (yes 2 times uportal):
> /var/www/uportal/
> uportal/
Change the above to ROOT/.
> ResourceServingWebapp/
That one is fine.
> I don't get why I had to specify ROOT in the docBase argument.
You shouldn't have a docBase argument, because you don't need any <Context> elements at all.
> Is it not the value by default ?
No; there is no default for docBase, since it should be used only when a <Context> element is in conf/Catalina/[host]/[appName].xml, and the associated webapp is located outside of the <Host>'s appBase directory.
- 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Error 404 when redirected
Posted by arnaud icard <ar...@univ-avignon.fr>.
Caldarale, Charles R a écrit le 07/10/2010 13:50:
>> I am currently installing and configuring a
>> webserver with the couple httpd/tomcat.
>>
> Exact versions?
>
httpd : Apache/2.2.9 (Debian)
tomcat : Apache Tomcat/6.0.29
>> My current Tomcat configuration is something like that :
>> <Host name="appli1.domain.fr" appBase="/var/www/appli1"
>> unpackWARs="true" autoDeploy="true" xmlValidation="false"
>> xmlNamespaceAware="false">
>> <Context path="" docBase="/var/www/appli1" crossContext="false">
>>
> The above is seriously broken. First, it is absolutely illegal to have the appBase the same as docBase.
Indead. This page helped me to understand why :
http://www.lisnichenko.com/articles/tomcat-appbase-and-docbase.html
> Second, you should not be placing<Context> elements in server.xml.
This is not completly true :
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
I quote the webpage :
*Context* elements may be explicitly defined:
* ...
* Inside a Host element in the main conf/server.xml.
This is what I did there. But I guess this is the complete opposite to
what is written just above on the same webpage.
> Third, each<Host> should have a unique appBase directory.
This is already the case, isn't it?
> Fourth, the default webapp for a given appBase must be named ROOT (case sensitive)
>
I had to made an exception for an application (uPortal) which is
deployed in an uPortal/ folder
But I corrected this for the others.
> Remove the<Context> elements from server.xml, and restructure your file layout to look like this:
>
Most of these applications are deployed using /ant deploy/.
Thus I cannot place context file in the application/ROOT/META-INF (well
I could but it would mean that I had to copy the context file each time
I launch /ant deploy/)
So I now have the following server.xml :
<Host name="appli1.domain.fr" appBase="/var/www/appli1"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="ROOT" crossContext="false">
...
<Host name="appli2.domain.fr" appBase="/var/www/appli2"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="ROOT" crossContext="false">
...
<Host name="uportal.domain.fr" appBase="/var/www/uportal"
unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="uportal" crossContext="false">
...
<Context path="/ResourceServingWebapp"
docBase="ResourceServingWebapp" crossContext="false">
...
The file layout for uportal is (yes 2 times uportal):
/var/www/uportal/
uportal/
ResourceServingWebapp/
Everything works fine... but I don't get why I had to specify ROOT in
the docBase argument. Is it not the value by default ?
Regards,
arnaud
> /
> var/
> www/
> appli1/
> ROOT/
> META-INF/
> context.xml
> WEB-INF/
> classes/
> lib/
> <other appli1 directories and files>
> appli2/
> ROOT/
> META-INF/
> context.xml
> WEB-INF/
> classes/
> lib/
> <other appli2 directories and files>
>
> The context.xml file in each ROOT's META-INF directory can actually be omitted for the two webapps you showed, since it would contain no useful information (the path and docBase attributes must not be used here). Only if you had some non-default attribute to specify would you create a<Context> element inside it.
>
> - 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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
RE: Error 404 when redirected
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: arnaud icard [mailto:arnaud.icard@univ-avignon.fr]
> Subject: Error 404 when redirected
> I am currently installing and configuring a
> webserver with the couple httpd/tomcat.
Exact versions?
> My current Tomcat configuration is something like that :
> <Host name="appli1.domain.fr" appBase="/var/www/appli1"
> unpackWARs="true" autoDeploy="true" xmlValidation="false"
> xmlNamespaceAware="false">
> <Context path="" docBase="/var/www/appli1" crossContext="false">
The above is seriously broken. First, it is absolutely illegal to have the appBase the same as docBase. Second, you should not be placing <Context> elements in server.xml. Third, each <Host> should have a unique appBase directory. Fourth, the default webapp for a given appBase must be named ROOT (case sensitive).
Remove the <Context> elements from server.xml, and restructure your file layout to look like this:
/
var/
www/
appli1/
ROOT/
META-INF/
context.xml
WEB-INF/
classes/
lib/
<other appli1 directories and files>
appli2/
ROOT/
META-INF/
context.xml
WEB-INF/
classes/
lib/
<other appli2 directories and files>
The context.xml file in each ROOT's META-INF directory can actually be omitted for the two webapps you showed, since it would contain no useful information (the path and docBase attributes must not be used here). Only if you had some non-default attribute to specify would you create a <Context> element inside it.
- 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Error 404 when redirected
Posted by arnaud icard <ar...@univ-avignon.fr>.
Hi André,
this difference is due to a slight modification I made.
The error is the same with the original code.
André Warnier a écrit le 07/10/2010 12:33:
> arnaud icard wrote:
> ...
>>
>> It's working for every applications except the appli2.
>> The appli2 interprets the index.jsp which redirects to
>> http://appli2.domain.fr/stylesheets/welcome.faces.
>> At this point I have a 404 error : /The requested resource
>> (/stylesheets/cas.faces) is not available./
>>
>> How could it interprets the index.jsp but then cannot find the
>> /stylesheets/welcome.faces ?
>> Does it come from my configuration or may it come from the application ?
>>
> Hi.
> I have no idea if this may be the cause of the problem, but I notice a
> discrepancy between what you are writing, and the error message.
> It is not complaining about the "welcome.faces", but about not finding
> the "cas.faces".
> May it be that there is a link in "welcome.faces" which should point
> to "cas.faces", but is incorrect ?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Re: Error 404 when redirected
Posted by André Warnier <aw...@ice-sa.com>.
arnaud icard wrote:
...
>
> It's working for every applications except the appli2.
> The appli2 interprets the index.jsp which redirects to
> http://appli2.domain.fr/stylesheets/welcome.faces.
> At this point I have a 404 error : /The requested resource
> (/stylesheets/cas.faces) is not available./
>
> How could it interprets the index.jsp but then cannot find the
> /stylesheets/welcome.faces ?
> Does it come from my configuration or may it come from the application ?
>
Hi.
I have no idea if this may be the cause of the problem, but I notice a discrepancy between
what you are writing, and the error message.
It is not complaining about the "welcome.faces", but about not finding the "cas.faces".
May it be that there is a link in "welcome.faces" which should point to "cas.faces", but
is incorrect ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org