6 Replies Latest reply on Dec 23, 2008 5:05 PM by 655221

    Redirect to Error page when an exception occuers

    676901
      Hello,

      I want to catch all exceptions, it may happen in the main portal page or inside a portlet.
      When ever there is an exception, I want to redirect the user to and tell him to try after sometime.

      I already have such a feature for 404 (page not found), which works fine.
      But for exception its not working

      The setting in have in web.xml is

           <error-page>
           <error-code>404</error-code>
           <location>/error.jsp</location>
           </error-page>
           
           
           <error-page>
           <exception-type>java.lang.Exception</exception-type>
           <location>/error.jsp</location>
           </error-page>


      I even tried putting exact exception thrown from the on screen stack trace, like

      <error-page>
           <exception-type>javax.ejb.EJBException</exception-type>
           <location>/error.jsp</location>
           </error-page>

      But still no use. I get the main portal's header and then the menu bar, and few portlets and the one portlet that is generating exception, still prints the full stack trace and that kills the alignment, making a complete mess.


      I have weblogic 10.2 or weblogic 10.3.


      Is there any way, I can catch, where ever exception happens and redirect the user to the custom error page.


      Thanks in Advance

      --
      Parvez
        • 1. Re: Redirect to Error page when an exception occuers
          672451
          a. Override your skeletons error.jsp to forward/redirect to your page.
          or
          b. If you primarily use pageflow portlets Define a shared flow which has an exception handling method and direct it to your page. Reference the shared flow in each of your controllers (i think global.app is deprecated in 10 otherwise you could do this there). this lets you log some additional information, plus gives you the added flexibility of dealing with different exception types
          or
          c. Override the path to error.jsp in your portlets properties (havent tested)


          Note if you are using servlets etc you still need your web.xml java.lang.Exception entry. The reason it doesnt get picked up is because the portal framework is handling the exception

          Edited by: deepshet on Dec 22, 2008 8:12 PM
          • 2. Re: Redirect to Error page when an exception occuers
            672488
            You can add following entry in your .portlet file for handling errors in portlets

            <netuix:proxyPortletContent errorUri="/portlet-error.jsp"/>
            • 3. Re: Redirect to Error page when an exception occuers
              676901
              Thanks Mr deepshet for your answers.


              a) Would you be kind enough to tell me what is the location of the skeletons error.jsp

              b) Defining a shared flow, I don't think this is possible as we are at the fag end of the project. Anyways i will try to edit the global.app.
              Again would you be kind enough to tell me, where to look for, the global.app.

              c) Does not look like it has any such properties


              Thanks a lot (a) and (b) seem promising but need elaborate change.

              There should be some better solution. I am sure many people have implemented this.

              Anyone out there who has done this, Please share the info
              • 4. Re: Redirect to Error page when an exception occuers
                676901
                Mr vkp,

                That sounds interesting, Will try it tomorrow morning.

                but again, we have like 200 odd portlets, Is there no way we can go on adding to each one of it.


                Is there any such property in .portal itself for all portlets inside it ?
                • 5. Re: Redirect to Error page when an exception occuers
                  672451
                  hi

                  a. if you dont have an error.jsp, look at the merged projects view in eclipse/workshop and copy that file to your project to your skeleton, and make modifications to it(window--> show view--> merged projects). Should be under the default skeleton.

                  b. Look at
                  http://beehive.apache.org/docs/1.0.2/netui/sharedFlow.html
                  http://beehive.apache.org/docs/1.0.2/netui/exceptionHandling.html
                  If you need a code snippet let me know

                  c. If you look at the properties window for your portlet there should be a property called Error Page path

                  regards
                  deepak
                  • 6. Re: Redirect to Error page when an exception occuers
                    655221
                    This doesn't apply unless you are using JSR-168 portlets, but just in case: I saw a similar internal thread recently in which the developer was working with a JSR 168 portlet and could not get their customized skeleton error.jsp to take effect. This is what a portal guru told him:

                    Yes- it makes a big difference that you are using JSR168 portlets! You can specify the error page that gets redirected to in weblogic-portlet.xml.

                    For example:

                    <portlet>
                    <portlet-name>myPortletName</portlet-name>
                    <supports>
                    <mime-type>text/html</mime-type>
                    <error-uri>/myPortlets/common/error.jsp</error-uri>
                    </supports>
                    </portlet>