You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shelley <ra...@gmail.com> on 2013/03/20 20:41:23 UTC

501 error not going to location

I've configured an error-page in my web.xml to handle 501 error-codes, but
the resource specified in the location entry is not being returned by the
container as expected.

Here is the content of my web deployment descriptor. Note that the 404
error-page works as expected, but the 501 error-page does not.

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

    <error-page>
        <error-code>404</error-code>
        <location>/404</location>
    </error-page>
    <error-page>
        <error-code>501</error-code>
        <location>/501</location>
    </error-page>

</web-app>

Without an error-page element for the 501, the default Tomcat HTML error
page is returned with a status code of 501. When I add the error-page
element, the response status code is 501 but no content is returned
(Content-Length: 0). Instead, I would expect the content of my "/501"
location to be returned. (This is the exact problem that was described in
this thread [1] a couple years ago, but this thread did not seem to have an
answer/conclusion.)

This is occurring on Apache Tomcat 7.0.37.

Is there some additional configuration or modification needed for Tomcat to
honor the error-page location, or is this a bug?

[1]
http://mail-archives.apache.org/mod_mbox/tomcat-users/201109.mbox/%3C32475425.post@talk.nabble.com%3E

Re: 501 error not going to location

Posted by Shelley <ra...@gmail.com>.
>
> 1. How to you send your error and how do you test it?
>

I'm testing the error with simple HTTP clients that send requests using
HTTP methods that the container and my app don't support by default (e.g.
COPY, PROPFIND). While debugging my app, it's clear that the HTTP method
and request are being sent correctly, and it seems that the Tomcat
container's HttpServlet implementation handles sending the 501 error.

2. You may try debugging, w3ith a breakpoint in o.a.catalina.core.


Thanks, I may try that.

> 3. What is your error page? A servlet, a static file, a JSP?
>>
> It is a servlet, but I've also tested using a static HTML file, which
doesn't work either.

4. 501 is "invalid method".  I wonder whether it tries to serve the error
> page itself using the same "wrong" method. E.g. the DefaultServlet
> processes only valid methods (GET, POST, HEAD, ...).


I think this may be what's happening. When the container HTTPServlet
receives the request for the error-page it's still using the original
method and so it's unable to serve up the error-page (again).

I'll try to do some more debugging of Tomcat's code to understand what's
happening, but in the meantime, I'd appreciate any other thoughts or ideas
as to how custom 501 error pages may be handled. Thanks!


On Wed, Mar 20, 2013 at 3:01 PM, Konstantin Kolinko
<kn...@gmail.com>wrote:

> 2013/3/20 Shelley <ra...@gmail.com>:
> > I've configured an error-page in my web.xml to handle 501 error-codes,
> but
> > the resource specified in the location entry is not being returned by the
> > container as expected.
> >
> > Here is the content of my web deployment descriptor. Note that the 404
> > error-page works as expected, but the 501 error-page does not.
> >
> > <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> > java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
> >
> >     <error-page>
> >         <error-code>404</error-code>
> >         <location>/404</location>
> >     </error-page>
> >     <error-page>
> >         <error-code>501</error-code>
> >         <location>/501</location>
> >     </error-page>
> >
> > </web-app>
> >
> > Without an error-page element for the 501, the default Tomcat HTML error
> > page is returned with a status code of 501. When I add the error-page
> > element, the response status code is 501 but no content is returned
> > (Content-Length: 0). Instead, I would expect the content of my "/501"
> > location to be returned. (This is the exact problem that was described in
> > this thread [1] a couple years ago, but this thread did not seem to have
> an
> > answer/conclusion.)
> >
> > This is occurring on Apache Tomcat 7.0.37.
> >
> > Is there some additional configuration or modification needed for Tomcat
> to
> > honor the error-page location, or is this a bug?
> >
> > [1]
> >
> http://mail-archives.apache.org/mod_mbox/tomcat-users/201109.mbox/%3C32475425.post@talk.nabble.com%3E
>
> 1. How to you send your error and how do you test it?
>
> 2. You may try debugging, w3ith a breakpoint in
> o.a.catalina.core.StandardHostValve.status(..)
> http://wiki.apache.org/tomcat/FAQ/Developing#Debugging
>
> 3. What is your error page? A servlet, a static file, a JSP?
>
> 4. 501 is "invalid method".  I wonder whether it tries to serve the
> error page itself using the same "wrong" method. E.g. the
> DefaultServlet processes only valid methods (GET, POST, HEAD, ...).
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: 501 error not going to location

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/3/20 Shelley <ra...@gmail.com>:
> I've configured an error-page in my web.xml to handle 501 error-codes, but
> the resource specified in the location entry is not being returned by the
> container as expected.
>
> Here is the content of my web deployment descriptor. Note that the 404
> error-page works as expected, but the 501 error-page does not.
>
> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
>
>     <error-page>
>         <error-code>404</error-code>
>         <location>/404</location>
>     </error-page>
>     <error-page>
>         <error-code>501</error-code>
>         <location>/501</location>
>     </error-page>
>
> </web-app>
>
> Without an error-page element for the 501, the default Tomcat HTML error
> page is returned with a status code of 501. When I add the error-page
> element, the response status code is 501 but no content is returned
> (Content-Length: 0). Instead, I would expect the content of my "/501"
> location to be returned. (This is the exact problem that was described in
> this thread [1] a couple years ago, but this thread did not seem to have an
> answer/conclusion.)
>
> This is occurring on Apache Tomcat 7.0.37.
>
> Is there some additional configuration or modification needed for Tomcat to
> honor the error-page location, or is this a bug?
>
> [1]
> http://mail-archives.apache.org/mod_mbox/tomcat-users/201109.mbox/%3C32475425.post@talk.nabble.com%3E

1. How to you send your error and how do you test it?

2. You may try debugging, w3ith a breakpoint in
o.a.catalina.core.StandardHostValve.status(..)
http://wiki.apache.org/tomcat/FAQ/Developing#Debugging

3. What is your error page? A servlet, a static file, a JSP?

4. 501 is "invalid method".  I wonder whether it tries to serve the
error page itself using the same "wrong" method. E.g. the
DefaultServlet processes only valid methods (GET, POST, HEAD, ...).

Best regards,
Konstantin Kolinko

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