投稿者this投稿私は別の質問を考えていますが、私はインターウェブ上の答えを見つけることができないようです。サーブレット例外スタックトレースの出力を非表示/処理します
セッションタイムアウトを検出し、エラーページにリダイレクトするサーブレットフィルタがあります。私の初心者のJavaのために私は例外をキャッチし、正常にそれらを処理するキャッチブロックを使用しましたが、セッションのタイムアウト状況では、コンテキストが無効なので、私はそれを行うことができます任意のコードを持っているとは思わない私はそれを処理するフィルタを持っているにもかかわらず、私のログに表示される 'viewIdは復元できませんでした'ステイストレースを停止します。
例外トレースがログに表示されないようにするにはどうすればよいですか?ライブで自動的に監視され、この種のエラーのためにサポートチームに誤った肯定的な呼びかけがあります。
助けてください。より明確にすることが
EDIT
、私のコードクリップは現在
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
try {
chain.doFilter(request, response);
} catch (ServletException e) {
logger.error("Caught Servlet Exception");
Throwable rootCause = e.getRootCause();
logger.error("Root cause is " + rootCause.toString());
if (rootCause instanceof RuntimeException) { // This is true for any FacesException.
logger.error("Rethrowing exception as RuntimeException" + rootCause.toString());
throw (RuntimeException) rootCause; // Throw wrapped RuntimeException instead of ServletException.
} else {
throw e;
}
}
}
ログは言うです:
|STDOUT| 2011-01-19 10:40:57,803 | ERROR | [http-8080-5]: Exception in the filter chain
javax.servlet.ServletException: viewId:/index.jsf - View /index.jsf could not be restored.
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
<snip>
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
<snip>
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
... 21 more
19-Jan-2011 10:40:57 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
<snip>
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
|STDOUT| 2011-01-19 10:40:57,803 | ERROR | [http-8080-5]: Caught Servlet Exception
|STDOUT| 2011-01-19 10:40:57,803 | ERROR | [http-8080-5]: Root cause is javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
|STDOUT| 2011-01-19 10:40:57,803 | ERROR | [http-8080-5]: Rethrowing exception as RuntimeExceptionjavax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
あなたがコードから見ることができるように、私はしましたフィルタでサーブレットの例外を検出しましたが、スタックにログが残っています。次のように私のweb.xml内のフィルタの
次の編集 完全なリストは、次のとおりです。
<filter>
<filter-name>Error</filter-name>
<filter-class>prismClient.ErrorFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Error</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
私は自分でフィルタを書きました。あなたの例は本質的に私が既に書いたものです(私はhttpプロトコルに私のものを限定していません)。より具体的に私の投稿を編集しました。 – volvox
あなたはそこでViewExpiredExceptionを処理しません。 –
いいえ、私はそれが何であるかRunTimeExceptionとして扱います。 – volvox