0

I am working on exception handling in our Application. I used try catch blocks to catch the exceptions occured in my code and i also could handle the time out exceptions by writing a listener and registering the listener in "faces-config.xml".

But i am facing problems in catching unexpected errors like "NullPointerException" in constructor or error Codes 500, 400 etc.

i used the tags in the "web.xml"

<error-page>
      <exception-type>java.lang.Exception</exception-type>
      <location>/sc00/ErrorPage.jsp</location>
</error-page>

I tried many ways to handle the exceptions, can any one help me in finding out a solution. The error i am getting when i try to handle these exceptions is as follows.

I am using JSF 1.2 and the server is websphere 8

The Console shows the Following Exception.

com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException

E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: An exception was thrown by one of the service methods of the servlet [/sc00/ErrorPage.jsp] in application [MembershipEligibilityScreensEAR]. Exception created : [java.lang.RuntimeException: FacesContext not found

My Error Page is in /WebContent/sc00/ErrorPage.jsp, ErrorPage.jsp has no backing bean associated with it.

Many solutions asked me to look at the URL path of Faces Servlet, In My web.xml the servlet-mapping is a follows

 <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

all the paths in my faces-config.xml refer to /FolderName/JspName and they work fine and they work fine even in Navigation.xml.

How can i navigate it to ErrorPage.jsp, Is there any way so that i can write a listener to this kind of problem

Sorry for posting too many redundant questions, i am new to JSF and i don't know the rules of StackOverflow, I apologize for the problem i have caused.

any solution would be appreciated.

4

1 回答 1

0
 java.lang.RuntimeException: FacesContext not found 

FacesServlet当您通过一个与(谁是负责创建 的)的 URL 模式不匹配的 URL 请求包含 JSF 组件的 JSP 页面时,就会发生这种情况FacesContext

您需要更改错误页面位置以匹配中FacesServlet定义的 URL 模式web.xml。根据您对该主题的重复问题,这是除其他*.faces外,因此应该按照以下方式设置错误页面位置,正如我在对您关于该主题的第一个问题的评论中所建议的那样。

<location>/sc00/ErrorPage.faces</location>
于 2012-11-12T23:54:01.557 回答