4 Replies Latest reply on Nov 6, 2008 10:51 AM by Eugene Kashin

    Custom error pages in Seam 2

    Eugene Kashin Newbie


      There is very powerful concept of custom error pages in Seam 2. We have use it too in our application, but there is some problem in most cases. Our application is running on Jboss-4.2.1GA.

      The implementation: in file pages.xml there is a block of exception cases, each case defines a behavior of the application in of exception of specified type, for example:


      <exception class="org.jboss.seam.framework.EntityNotFoundException">
              <redirect view-id="/error.xhtml">
                  <message>Not found</message>

      It doesn't work properly, as I've said, in most cases, and we still have standard error page with a stacktrace. As far as I could understand, it happens because server is not able to redirect to another resource, when rendering of the page is started already. Something like that. How can I use the custom errors of Seam in spite of this? Is there any workaround or am I just doing it wrong way?

      Thanks in advance!

        • 1. Re: Custom error pages in Seam 2
          João Bosco Monteiro Newbie

          Hi Eugene,

          Please, check if you have a default redirect for Exception. Something like:

            <redirect view-id="/error.xhtml">
                <message severity="WARN">#{org.jboss.seam.exception.message}</message>

          I suspect that you are getting an untreated exception.

          • 2. Re: Custom error pages in Seam 2
            Eugene Kashin Newbie

            Hi, Joao,

            I had thought so, but it is not the case. We are catching even most general exceptions, and we could see from logs that exeption is caught exactly in place we expected it to be, but redirect doesn't occur. By the way, in case of NotLoggedInException, redirect works fine. I have been explained, that the problem is that the system cannot perform redirection, once http headers were written already. And that is what I want to prevent.
            We have default redirect for Exception, that you have mentioned here:

                    <redirect view-id="/error.xhtml">
                        <message>Unexpected error, please try again</message>

            Well, do you have some other idea?


            • 3. Re: Custom error pages in Seam 2
              Dan Allen Master

              In all likelyhood, the error page that you are seeing in the Facelets development page. If you want Seam to be able to catch all exceptions, you should disable Facelets development mode in web.xml and disable Seam debug mode as well.


              In rare cases, even Facelets/JSF cannot catch the error page. In those cases, you can resort to the exception handling facility in web.xml.

              • 4. Re: Custom error pages in Seam 2
                Eugene Kashin Newbie


                Many thanks, it seems to have helped (I've just disabled Facelets development mode as you suggested). I am trying to see how the system behaves in case of various exceptions, but the direction is clear now. Thanks again!