2008-09-23 170 views
2

如果我的代碼拋出異常,有時(而不是每次都) - jsf顯示空白頁面。我正在使用facelets進行佈局。 這個Sun forumn´s post報告了類似的錯誤,但沒有答案。 其他人有相同的問題,或有解決方案? ;)JSF中的空白頁面

由於一些請求。下面就跟隨更datails:

的web.xml

<error-page> 
     <exception-type>com.company.ApplicationResourceException</exception-type> 
     <location>/error.faces</location> 
</error-page> 

以及與JSF堆棧是真正的異常後打印:使用JSF版本

####<Sep 23, 2008 5:42:55 PM GMT-03:00> <Error> <HTTP> <comp141> <AdminServer> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1222202575662> <BEA-101107> <[[email protected] - appName: 'ControlPanelEAR', name: 'ControlPanelWeb', context-path: '/Web'] Problem occurred while serving the error page. 
javax.servlet.ServletException: viewId:/error.xhtml - View /error.xhtml could not be restored. 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:249) 
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226) 
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124) 
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) 
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) 
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:525) 
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:261) 
    at weblogic.servlet.internal.ForwardAction.run(ForwardAction.java:22) 
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) 
    at weblogic.security.service.SecurityManager.runAs(Unknown Source) 
    at weblogic.servlet.internal.ErrorManager.handleException(ErrorManager.java:144) 
    at weblogic.servlet.internal.WebAppServletContext.handleThrowableFromInvocation(WebAppServletContext.java:2201) 
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2053) 
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366) 
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) 
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:172) 
javax.faces.application.ViewExpiredException: viewId:/error.xhtml - View /error.xhtml could not be restored. 
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:180) 
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248) 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) 
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226) 
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124) 

I'm Mojarra 1.2_09richfaces 3.2.1.GAfacelets 1.1.13

希望一些幫助:(

+0

你介意給我們一點細節嗎?你正在使用什麼實現以及如何配置你的錯誤處理系統。 – sblundy 2008-09-23 20:59:59

+0

我重新編輯了這個問題。請看一下。 ;) – paulosuzart 2008-09-23 21:20:56

回答

2

我認爲這很大程度上取決於你的JSF實現。我聽說有些人會呈現空白屏幕。

我們使用將引發錯誤500與堆棧的一個跟蹤其他超時按鈕不會在沒有任何錯誤的情況下工作,這一切都在我們的開發階段

但我可以給你的最好建議是捕獲異常並將它們記錄在錯誤日誌中你有堆棧跟蹤用於稍後的調試。對於我們無法做任何事情的消息,像後端失敗,我們w只需在屏幕上顯示的FacesContext中添加一條致命消息並記錄堆棧跟蹤。

+0

感謝您的回答。其實這很難過。好的建議,我們已經跟隨,但問題仍然存在。 這一點是完全趕上什麼,以避免這種行爲。 :( 謝謝。 – paulosuzart 2008-09-23 21:19:47

+0

以及我在我的應用程序中看到有時頁面被加載blank.the原因被發現是太多的文件被打開在我的應用程序在BG活動和文件流沒有被關閉在一些地方 – Inv3r53 2010-04-04 15:23:11

1

我在今天的error.jsp頁面中修復了類似的問題。這不會和你的完全一樣,但如果他們遇到類似的問題,它可能會指向某個正確的方向。我的問題似乎來自兩個不同的來源。

首先,message異常屬性未在某些引發錯誤頁面捕獲異常的servlet中設置。這些servlet使用構造函數ServletException(Throwable rootCause)捕獲並重新拋出異常。

其次,在錯誤頁面本身,原作者使用scriptlet代碼來解析消息,使用String.split(message, ";");由於消息是null這失敗了。我在我的錯誤日誌中收到了一個NullPointerException以及「服務錯誤頁面時發生問題」消息。

這兩件事結合在一起,給了我一個空白頁面,該頁面是拋出原始異常的servlet的URL。當我使用ServletException(String message, Throwable rootCause)構造函數在Servlet中重新引發異常時,我通過提供自己的錯誤消息解決了我的問題,因此錯誤消息將不再爲null。我還使用EL代替了scriptlet代碼重寫了error.jsp頁面,但這不是嚴格必要的。

-1

有關JSF 2空白頁,放在ExceptionHandlerWrapper.handle斷點或類中重寫此方法。在我的情況下,這是由於自定義代碼太限制了,錯誤沒有記錄。