Note that there are some explanatory texts on larger screens.

plurals
  1. POHide/handle servlet exception stack trace output
    primarykey
    data
    text
    <p>From <a href="https://stackoverflow.com/questions/4716030/javax-faces-application-viewexpiredexception-seemingly-ignored">this</a> post I have thought of another question I cannot seem to find the answer to on the interweb. </p> <p>I have a servlet filter which detects session timeouts and redirects to an error page. Due to my fledgling java I've used try catch blocks to catch exceptions and handle them gracefully, but in a session timeout situation, the context is invalid so I don't think I've got any code I can do that with which will stop the 'viewId could not be restored' stace trace appearing in my log even though I have a filter handling it.</p> <p>How can I stop the exception trace from appearing in my log? It will be monitored autoamtically in live and it will be a false positive call out to the support team for this sort of error.</p> <p>Any help appreciated.</p> <p><em>EDIT</em></p> <p>To be more clear, my code clip is currently</p> <pre><code>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; } } } </code></pre> <p>The log says:</p> <pre><code> |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) &lt;snip&gt; at java.lang.Thread.run(Unknown Source) Caused by: javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored. &lt;snip&gt; 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) &lt;snip&gt; 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. </code></pre> <p>As you can see from the code, I've caught the servlet exception in the filter, but the stack is still appearing in the log.</p> <p><em>NEXT EDIT</em> The complete list of filters in my web.xml is as follows:</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;Error&lt;/filter-name&gt; &lt;filter-class&gt;prismClient.ErrorFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;Error&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;filter&gt; &lt;display-name&gt;RichFaces Filter&lt;/display-name&gt; &lt;filter-name&gt;richfaces&lt;/filter-name&gt; &lt;filter-class&gt;org.ajax4jsf.Filter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;richfaces&lt;/filter-name&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt; &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt; &lt;/filter-mapping&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload