4 Replies Latest reply on May 16, 2007 7:00 PM by susnet

    Exception handling with @HttpError not working

    susnet

      My Exception class:

      @ApplicationException(rollback=true)
      @HttpError (errorCode=HttpServletResponse.SC_NOT_FOUND)
      public class PageNotFoundException extends Exception {
      
      
       /** Creates a new instance of PageNotFoundException */
       public PageNotFoundException () {
       super ("Page not found");
       }
      }
      


      In web.xml

      <error-page>
       <error-code>404</error-code>
       <location>/pages/error/error404.xhtml</location>
       </error-page>
      


      Instead I get a 500 error.

      Why is this not working? Any ideas?

      I use Seam 1.2.1 on JBoss 4.0.5. I don't have any other problems with my application.

        • 1. Re: Exception handling with @HttpError not working
          susnet

          In web.xml I also have:

          <filter>
           <filter-name>Seam Filter</filter-name>
           <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>Seam Filter</filter-name>
           <url-pattern>/*</url-pattern>
           </filter-mapping>
          


          When I deploy my app i can read in the log:

          INFO [Lifecycle] starting up: org.jboss.seam.servlet.exceptionFilter


          • 2. Re: Exception handling with @HttpError not working
            susnet

            If I put

             <exception>
             <end-conversation/>
             <redirect view-id="/pages/error/error404.xhtml">
             <message>Unexpected Failure. </message>
             </redirect>
             </exception>
            


            in pages.xml, it does not work either. The exception just falls through and an ugly error message will be shown (if i'm not adding an errorpage for 500 in web.xml).

            I have <core:init debug="false" .. in my components.xml.

            I have searched the internet, read in this forum, read the seam manual 1.2.1 and I've spent several nights testing everything i can come up with but I can't get this to work. Please help!

            • 3. Re: Exception handling with @HttpError not working
              susnet

              The problem was solved by adding

              <context-param>
               <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
               <param-value>client</param-value>
               </context-param>


              to web.xml.

              • 4. Re: Exception handling with @HttpError not working
                susnet

                No, forget what i wrote in my last post.
                The problem was that i'm using Tuckey URLRewrite. Then the Seam filter must come BEFORE the URLRewriteFilter in web.xml.

                Like this:

                <filter>
                 <filter-name>Seam Filter</filter-name>
                 <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
                 </filter>
                 <filter-mapping>
                 <filter-name>Seam Filter</filter-name>
                 <url-pattern>/*</url-pattern>
                 </filter-mapping>
                
                 <filter>
                 <filter-name>UrlRewriteFilter</filter-name>
                 <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
                 <init-param>
                 <param-name>confReloadCheckInterval</param-name>
                 <param-value>0</param-value>
                 </init-param>
                 <init-param>
                 <param-name>logLevel</param-name>
                 <param-value>WARN</param-value>
                 </init-param>
                 </filter>
                 <filter-mapping>
                 <filter-name>UrlRewriteFilter</filter-name>
                 <url-pattern>/*</url-pattern>
                 </filter-mapping>