Menu

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

ADF, Exceptions, Portal By Oct 07, 2014 No Comments
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.

Solution:

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() {
        super();
    }
    public void
init(FilterConfig filterConfig) throws ServletException {
        fc = filterConfig;
    }
    public void
doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain) throws IOException,
ServletException {
        String reqSessionID =
((HttpServletRequest)servletRequest).getreqSessionIDId();
        String currentSessionID
=
((HttpServletRequest)servletRequest).getSession().getId();
        String requestURI =
((HttpServletRequest)servletRequest).getRequestURI();
        boolean sameSession =
currentSessionID.equalsIgnoreCase(reqSessionID);
System.out.println(“currentSessionID == reqSessionID? : ” +
sameSession);
        if (!sameSession
&& reqSessionID != null) {
//((HttpServletResponse)servletResponse).sendRedirect(requestURI);
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.
<filter>
 <filter-name>AppSessionFilter</filter-name>
<filter-class>portal.MyFilter</filter-class>
 </filter>
<filter-mapping>
<filter-name>AppSessionFilter</filter-name>
   <servlet-name>Faces
Servlet</servlet-name>
</filter-mapping>

No Comments

Leave a comment

Hi, Welcome here.
JOIN OUR NEWSLETTER
And get notified everytime we publish a new blog post.