custom error page not working

Splash Forums PrettyFaces Users custom error page not working

This topic contains 12 replies, has 3 voices, and was last updated by  m1m 5 years, 8 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #18027

    m1m
    Participant

    Hi

    I’m using jsf 2.0 with prettyfaces 3.3.0. My custom <error-page> in web.xml stopped working since using prettyfaces.

    <error-page>
    <exception-type>com.sun.faces.context.FacesFileNotFoundException</exception-type>
    <location>/error/500</location>
    </error-page>

    #21387

    Hi,

    what do you mean with “not working”? What do you see instead? Is /error/500 mapped using PrettyFaces?

    Christian

    #21388

    m1m
    Participant

    /error/* is a servlet doing redirection and logging. It’s not mapped in prettyfaces.

    I have the following mapping:

    <url-mapping id="page">
    <pattern value="/#{/\d+/id}/"/>
    <view-id value="/page.html"/>
    </url-mapping>

    But when I enter something not matching eg domain.com/1a2/ I got com.sun.faces.context.FacesFileNotFoundException but my servlet is not invoked. I see default browser error page

    #21389

    I guess you are getting a 404 instead of a 500 error code now, correct? I think previously your requests did always hit the FacesServlet (*.jsf or /faces/*) and Mojarra is throwing this exception if the page does not exist. But now your request won’t hit the FacesServlet because the URL doesn’t match the mapping of the FacesServlet. So you are just getting a 404 error, which is the more correct answer according to HTTP.

    You could try to map the 404 error page by doing something like this:

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

    #21390

    m1m
    Participant

    Actually, I already had 404 mapping, it dosen’t help

    #21391

    Hmmm! Which error code does the webapp send? 404? Did your custom 404 page work before? Does it work if you remove PrettyFaces?

    #21392

    I’ve actually seen this as well. I hadn’t thought that it was a PrettyFaces problem, though. For me it happens on several application servers.

    #21393

    Actually, just using JSF is enough to cause this issue for me sometimes.

    #21394

    Perhaps the custom error page doesn’t work if HttpServletResponse.sendError() is used!?!?!

    #21395

    Perhaps the custom error page doesn’t work if HttpServletResponse.sendError() is used!?!?!

    #21396

    I somehow doubt that, but if so, I guess it’s time to start looking for how to make a proper 404 page show up.

    #21397

    @lincoln:

    You are right. I just had a look at the spec (10.9.2):

    If the sendError method is called on the response, the container consults the list of

    error page declarations for the Web application that use the status-code syntax and

    attempts a match. If there is a match, the container returns the resource as indicated

    by the location entry.

    So this issue seems to have some other cause.

    #21398

    m1m
    Participant

    Yes, the problem is not in prettyfaces. Sorry for confusion.

    The solution is here:

    http://ocpsoft.com/support/topic/pwc4011-unable-to-set-request-character-encoding-to-utf-8-from-context

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Comments are closed.