2011-12-27 2 views
4

TomcatでJava 6、jsf 1.2を使用しています。特定のページからのタイムアウト後に操作を行うと、以下の例外が発生します。なぜエラーページの代わりに画面に例外が表示されますか?

私の質問は、ページが私のエラーページ/error/error.jsfにリダイレクトされないのはなぜですか?

これは、web.xmlの(私はフィルタを持っていません)です:

<error-page> 
    <exception-type>javax.faces.application.ViewExpiredException</exception-type> 
    <location>/error/error.jsf</location> 
</error-page> 
    <error-page> 
    <exception-type>java.lang.IllegalStateException</exception-type> 
    <location>/error/error.jsf</location> 
</error-page> 
<error-page> 
    <exception-type>java.lang.Exception</exception-type> 
    <location>/error/error.jsf</location> 
</error-page> 
<error-page> 
    <exception-type>org.springframework.beans.factory.BeanCreationException</exception-type> 
    <location>/error/error.jsf</location> 
</error-page> 

これは私のページ上のエラーメッセージです:例外はサーブレットコンテナにそれを作ることはありませんので

 

    An Error Occurred: 
    Error creating bean with name 'melaketViewHandler' defined in 
ServletContext resource [/WEB-INF/JSFViewHandlersContext.xml]: Instantiation 
of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [com.ewave.meuhedet.view.melaketViewHandlers.MelaketViewHandler]: Constructor threw 
exception; nested exception is java.lang.NullPointerException 

     - Stack Trace 

     org.springframework.beans.factory.BeanCreationException: Error creating bean 
    with name 'melaketViewHandler' defined in ServletContext resource 
    [/WEB-INF/JSFViewHandlersContext.xml]: Instantiation of bean failed; nested 
    exception is org.springframework.beans.BeanInstantiationException: Could not 
    instantiate bean class [com.ewave.meuhedet.view.melaketViewHandlers.MelaketViewHandler]: 
    Constructor threw exception; nested exception is java.lang.NullPointerException 

     at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254) 
... 

答えて

1

:それは扱いだ場合

public class ExceptionHandlingFaceletViewHandler extends FaceletViewHandler { 
    ... 

    protected void handleRenderException(FacesContext context, Exception exception) throws IOException, ELException, FacesException { 
    try { 
     if(context.getViewRoot().getViewId().matches(".*/error.jsf")) { 
     /* 
     * This is to protect from infinite redirects if the error page itself is updated in the 
     * future and has an error 
     */ 
     LOG.fatal("Redirected back to ourselves, there must be a problem with the error.xhtml page", exception); 
     return; 
     } 

     String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); 
     getHttpResponseObject().sendRedirect(contextPath + "/error"); 
    } 
    catch(IOException ioe) { 
     LOG.fatal("Could not process redirect to handle application error", ioe); 
    } 
    } 

    private HttpServletResponse getHttpResponseObject() { 
    return (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse(); 
    } 
} 
+0

ありがとう、それは動作します。 Wierdは例外なくExceptionHandlingFaceletViewHandlerのように見えますが、web.xml タグは無視されます。これは、Faceletが例外をキャッチするためです。 –

1

。スタックトレースのどこかに、それを処理するcatchがあります。

[EDIT]これをより明確にするには:(doGet()の内側)サーブレットの一部のコードが例外をキャッチし、e.printStackTrace(out);の同等を行います - コンテナ(doGet()と呼ばすなわちコード)が例外を見たことがありません、エラーページにリダイレクトするコードは決して呼び出されません。

Eclipseを使用している場合:スタックトレースをIDEにコピーします(Stacktrace Consoleを参照)。各スタックフレームをクリックすると、ソースが表示されます。例外をキャッチしてHTMLに変換するものを探します。私たちは、例外をキャッチし、エラーページにリダイレクトするカスタムビューハンドラ使用している

+0

を、なぜそれがスタックトレースに表示されていますか? –

+1

@DonRobyそれは処理であり、サーブレットはスタックトレースを表示します。 :) – Thomas

関連する問題