Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:00:51+00:00 2026-06-11T11:00:51+00:00

I have a JSF app which I want to ensure provides the user with

  • 0

I have a JSF app which I want to ensure provides the user with a meaningful response when it errors with an HTTP 500. The app dies when I force an OutOfMemoryError but I’m getting a default 500 error page from Tomcat 6.0.35.

Relevant parts of my app set up are:

web.xml:

<filter>
    <filter-name>Error</filter-name>
    <filter-class>myApp.ErrorFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Error</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

…

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/expiredIndex.jsf</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.jsf</location>
</error-page>

ErrorFilter.java:

public class ErrorFilter implements Filter {

static Logger logger = Logger.getLogger("MYAPP");

@Override
public void destroy() {
}

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    try {
        chain.doFilter(request, response);
    } catch (ServletException e) {
        logger.error(getDirID()+"|"+"Caught Servlet Exception");
        Throwable rootCause = e.getRootCause();
        logger.error(getDirID()+"|"+"Root cause is " + rootCause.toString());

        if (rootCause instanceof RuntimeException) { // This is true for any FacesException.
            logger.error(getDirID()+"|"+"Rethrowing exception as RuntimeException" + rootCause.toString());
            throw (RuntimeException) rootCause; // Throw wrapped RuntimeException instead of ServletException.
        } else {
            throw e;
        }
    }
}

@Override
public void init(FilterConfig arg0) throws ServletException {
}

public String getDirID() {
    DirID newDirID = new DirID();
    String dirID = newDirID.getDirID();

    return dirID;
}

}

The cut-down stack trace for your pleasure:

2012-09-17 17:35:51,881|ERROR|[http-8080-1]:Exception in the filter chain
javax.servlet.ServletException: Servlet execution threw an exception
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

…

Caused by: java.lang.OutOfMemoryError: Java heap space
at com.sun.facelets.util.FastWriter.overflow(FastWriter.java:50)
at com.sun.facelets.util.FastWriter.write(FastWriter.java:57)

…

 Sep 17, 2012 5:35:51 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
    at myApp.DirID.getDirID(DirID.java:27)
    at myApp.ErrorFilter.getDirID(ErrorFilter.java:50)
    at myApp.ErrorFilter.doFilter(ErrorFilter.java:31)

and probably the most relevant bit:

Sep 17, 2012 5:35:51 PM com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RESTORE_VIEW 1, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@16968dd]
Sep 17, 2012 5:35:51 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.application.ViewExpiredException: viewId:/error.jsf - View /error.jsf could not be restored.

Now my view on this is that the container dies when it hits the max memory limit and as such the error.jsf posh error page is not accessible given the state the stack is left in.

My questions are:

  1. Given the cause is a sudden out-of-memory error, can I get back from this so the server has enough to make the redirect to my error.jsf page?
  2. If the answer to 1 is yes, what is the most efficient method of implementation (preferably with a code snip-it for maximum guruness).

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:00:52+00:00Added an answer on June 11, 2026 at 11:00 am

    Basically, the answer for 1 would be no, you shouldn’t try to recover from an OOM error (more info here, and check the links provided in comments and answers). The error would be posted in your tomcat log and in your web application log (if any).

    If you get an OOM, I would use a Profiler like VisualVM to check where the problem could be and try to resolve the problem.

    Additional info:

    • How to Fix Memory Leaks in Java

    Another thing, you can handle the error using the error code, just add this in your web.xml:

    <error-page>
        <error-code>500</error-code>
        <location>/ErrorForCode500.html</location>
    </error-page>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a jsf page which displays an image from an url http://ichart.finance.yahoo.com/z?s=^NSEI&t=1d&q=l&l=on&z=l&p=s&a=v&p=s i
I have a JSF app on GlassFish. It's designed like so: user.xhtml > UserHandler.java
I have an app., coded with ejb3, jsf and maven, which runs on jboss
I have a JSF/Seam web app which has a page with a form which,
I have a web app which runs on JSF 2.0 + Richfaces 3.3.3. Looks
I have a Facelets(JSF 1.2 (myfaces)) web app and I want to customize my
I have a small JSF app and would like to keep some state on
I have a simple JSF web app as follows. The Java class contains: private
I have a JSR-168 portlet application in which some portlets use a JSF dataTable.
I have a small web application developed using Icefaces 1.8.2 and jsf 1.1 which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.