Handling Exception/Runtime Exception in JSF

Hi,

Any good pointers to documents describing proper error handling.

Not just navigation rules to an error.jsp file but also handling of runtime exceptions and exceptions in backing beans where you cannot use navigation rules (calling a method from JSF EL etc.).

I am developing jsr 168 portlets using jsf on websphere portal.

I can't get the error handling via web.xml to function and other places I can't manually make it go to an error.jsp in case of exceptions.

How to handle the runtime exception in JSF.

1. By including following tags in web.xml

<error-type>

<error-exception></error-exception>

<error-loaction>/error.jsp</error-loaction>

</error-type>

its not working.

2. If include the

<%@page errorPage="../error/GenericError.jsp" %>

in jsp page then

it is not forwading to error page giving asaertion failure exception

If we change the GenericError.jsp tag like

<f:view>

</f:view>

to

<f:subview>

</f:subview>

then it is going to error page but the

action inside the error page is not getting called its backing bean

Here is code of error.jsp

<%-- jsf:pagecode language="java" location="/JavaSource/pagecode/JSPs/ErrorPage1.java" --%><%-- /jsf:pagecode --%>

<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

<%@ page isErrorPage="true" %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

</head>

<body>

<div class="errorMessage"><%= exception.getLocalizedMessage() %></div>

<f:subview id="name">

<h:commandButton action="#{OSPMTASecurityBean.cancel}" value="submit"/>

</f:subview>

</body>

</html>

[2101 byte] By [sheetma] at [2007-11-26 18:53:03]
# 1
Check out this page: http://www.jroller.com/page/mert?entry=handling_errors_with_an_errrorVery helpful for handling errors in JSF. I've never used portlets, so I'm not sure if it'll work with them. You should try it though. Let us know how it goes!CowKing
IamCowKinga at 2007-7-9 6:27:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

If you would like to handle and navigate based on the exception type, this code would help you. btw I'm not familiar with portlet though.

http://sourceforge.net/projects/optionzero

http://sourceforge.net/forum/forum.php?forum_id=666191

You can declare exception type and navigation in faces-config.xml in declarative manner like Struts global exception notion.

Please let me know it's useful or not.

thanks,

Taka at 2007-7-9 6:27:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Hi, any success on this problem. I am also facing the same problem. Getting assertion error while forwarding to error page.. I am also developing jsr 168 portlets using jsf in websphere portal.Thanks in advanceelan
Elan.Va at 2007-7-9 6:27:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...