October 7, 2014

ADF_FACES-30108:The view state of the page has expired because of inactivity. Reload the page.

I have several tabs in my portal application, in which some of them are loading data from web services. Some times when I click on those tabs, an alert message with the below error message is displaying and on-click of Ok button, the app is reloading.

The error message:

ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RESTORE_VIEW 1
javax.faces.application.ViewExpiredException: viewId:/oracle/webcenter/portalapp/pages/home.jspx - ADF_FACES-30108:The view state of the page has expired because of inactivity.  Reload the page.


To ignore this error, I have written a filter which validates the app session on every navigation.  And my filter would look like,

package portal;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyFilter implements Filter {
    private FilterConfig fc = null;

    public MyFilter() {

    public void init(FilterConfig filterConfig) throws ServletException {
        fc = filterConfig;

    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException,
                                                         ServletException {
        String reqSessionID =
        String currentSessionID =
        String requestURI =
        boolean sameSession =
        System.out.println("currentSessionID == reqSessionID? : " + sameSession);
        if (!sameSession && reqSessionID != null) {
            System.out.println("Session is null");
        } else {
            filterChain.doFilter(servletRequest, servletResponse);
            System.out.println("Continue to servlet.");

    public void destroy() {
        fc = null;

Configured the above filter in web.xml file as below.
   <servlet-name>Faces Servlet</servlet-name>