I've a webapp with frameowrks JSF (Primefaces), Spring, Spring Security, PrettyFaces and Mybatis. Webapp have a login page as index page. When webapp is deployed for first time and I try log on occur IllegalArgumentException or ViewExpiredException depending jsf version. These exceptions ocurs for jsf version 2.1.3 and 2.1.0 respectively
Error Message IllegalArgumentException
java.lang.IllegalArgumentException: null source
java.util.EventObject.<init>(EventObject.java:38)
javax.faces.event.SystemEvent.<init>(SystemEvent.java:71)
javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:73)
javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:73)
com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:271)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:257)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
Error Message ViewExpiredException
javax.faces.application.ViewExpiredException: viewId:/login.xhtml - No se pudo restablecer la vista /login.xhtml.
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:202)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
Although I can solve this problem adding exception-handler-factory in faces-config file I'm surprised these exceptions occurs because as I have understood this only happens when the session expires, but if I just deploy the application, how is it possible that the session expires?
PD: Primefaces 3.5, Spring 3.1.1, Spring Security 3.1.3, PrettyFaces 3.3.3, Mybatis 3.1.1 Tomcat 6.0.10
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<description>indicar si estamos en desarrollo, en producción</description>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>Para poder utilizar comentarios xml</description>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>prettyFacesConfig</param-name>
<param-value>/WEB-INF/pretty-config.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>none</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>2097152</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
</web-app>
I solved my problem. In my login page I use dialog component. I change for panel component and exceptions lets to occur
Login Page (1st Version)
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:sec="http://www.springframework.org/security/tags"
template="/resources/template/template.xhtml">
<ui:define name="header"></ui:define>
<ui:define name="menu"></ui:define>
<ui:define name="content">
<h:form id="formLogin" prependId="false">
<p:dialog id="dlgLogin" header="SYSTEM" closable="false" resizable="false" draggable="false" visible="true"
width="480" height="340" position="center" styleClass="dlgNoTitle">
<p:messages id="messages" autoUpdate="true" closable="true" />
<p:graphicImage id="imgLogin" value="/resources/images/login1.jpg"
style=" left: 25px; position: relative; margin-top:10px" />
<p:panel styleClass="pnlNoTitle">
<h:panelGrid columns="2">
<h:outputLabel for="j_username" value="Usuario:"
style="font-weight: bold; color: grey; font-family:arial, sans-serif;"/>
<p:inputText value="#{loginController.user.username}" id="j_username" required="true" label="Usuario" />
<h:outputLabel for="j_password" value="Password:" style="font-weight: bold; color: grey; font-family:arial, sans-serif;"/>
<p:password value="#{loginController.user.password}" id="j_password" required="true" label="Password" />
<p:commandButton id="loginButton" value="Ingresar" icon="ui-icon-key" action="#{loginController.login}" ajax="false"
update="messages"/>
</h:panelGrid>
</p:panel>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
Login Page (2nd Version)
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:sec="http://www.springframework.org/security/tags"
template="/resources/template/template.xhtml">
<ui:define name="header"></ui:define>
<ui:define name="menu"></ui:define>
<ui:define name="content">
<div style="vertical-align: middle; position: relative; padding-top: 100px">
<h:form id="formLogin" prependId="false">
<p:panel id="pnlLogin"
style="width: 480px; height: 340px; margin: auto auto auto auto; ">
<p:messages id="messages" autoUpdate="true" closable="true" />
<p:graphicImage id="imgLogin" value="/resources/images/login1.jpg"
style=" left: 25px; position: relative; margin-top:10px" />
<p:panel styleClass="pnlNoTitle">
<div align="center">
<h:panelGrid columns="2">
<h:outputLabel for="j_username" value="Usuario:"
style="font-weight: bold; color: grey; font-family:arial, sans-serif;"/>
<p:inputText value="#{loginController.user.username}" id="j_username" required="true" label="Usuario" />
<h:outputLabel for="j_password" value="Password:" style="font-weight: bold; color: grey; font-family:arial, sans-serif;"/>
<p:password value="#{loginController.user.password}" id="j_password" required="true" label="Password" />
<p:commandButton id="loginButton" value="Ingresar" icon="ui-icon-key" action="#{loginController.login}" ajax="false"
update="messages"/>
</h:panelGrid>
</div>
</p:panel>
</p:panel>
</h:form>
</div>
</ui:define>
</ui:composition>
Now, the question is why this happens with the dialog component :)