JSF 2.3: Session expired vs ViewExpired problems - jsf

I am using JSF 2.3 (Mojarra), with PrimeFaces 7 on WildFly 17 and have a problem with (I suppose) an expired http ession, which I was not able to answer using the links below:
keep getting javax.faces.application.ViewExpiredException: viewId with jsf 2
JSF 2.3 Form Based Login and ViewExpiredException
To test my assumption I have put the following entry in my web.xml:
<session-config>
<cookie-config>
<http-only>true</http-only>
</cookie-config>
<session-timeout>1</session-timeout>
</session-config>
After deploying the application I opened two pages of it in different browsers:
The first page requires login that I performed successfully and then opened the page.
The second page requires a click on a link only (without login) and opens upon clicking this link.
Both pages use ViewScoped beans.
I wait a little more than one minute, when, according to the configuration above, the session should have expired.
1.) On the first page: when I click on the button below:
<p:commandButton icon="ui-icon-check" value="....." action="#{aveAngelBean.aveAngelegtOK}" update="#form" />
I only see that in the lower right corner a circle spins indicating that probably a JavaScript is executed, but nothing happens otherwise. I do not get any error in the console. When I click a second time on the button, nothing happens. Also, no code is executed on the server
2.) On the second page: when I click on the button below:
<p:commandButton icon = "ui-icon-check" value="#{msg['immobilien.ave.go.forward']}" action="#{persDatenBean.weiterUnterlagen}" update="#form">
<f:param name="validateOnWeiter" value="true"/>
</p:commandButton>
the #init method of the backing bean gets executed - meaning probably an attempt from the server to restore the view.
Then an error occurs, because the HTTP GET parameter, found in the URL of the link, which I initially invoked to get to this page:
?linkId=c91cc387-45f4-4c22-8829-4e3fd266c311_abd45a61-0e4e-4e7b-aa48-e9d858a5dbb9
is not being found.
My questions are:
1.) About the first page: How can I show the login-page instead of showing nothing?
2.) About the second page: How can I reload the page, when clicking the button, WITH the HTTP GET parameter that I used to initially invoke the page? Why is this parameter
?linkId=c91cc387-45f4-4c22-8829-4e3fd266c311_abd45a61-0e4e-4e7b-aa48-e9d858a5dbb9
somehow not considered at the time of pressing the button?
Below my web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>sapphire-#{guestPreferences.theme}</param-value>
</context-param>
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/primefaces-sapphire.taglib.xml</param-value>
</context-param>
<!-- #see http://jsfcorner.blogspot.co.at/2014/01/client-side-validation-example-of.html -->
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<filter>
<filter-name>Character Encoding Filter</filter-name>
<filter-class>org.primefaces.sapphire.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Character Encoding Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Job Repair Servlet</servlet-name>
<servlet-class>at.home.digest.web.ave.JobRepairServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>InitServlet Servlet</servlet-name>
<servlet-class>at.home.digest.web.ave.InitServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Download Servlet</servlet-name>
<servlet-class>at.home.digest.web.DownloadServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Job Repair Servlet</servlet-name>
<url-pattern>/ave/makler/admin/jobRep</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Download Servlet</servlet-name>
<url-pattern>/heimdi/ave/download</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Download Servlet</servlet-name>
<url-pattern>/ave/download</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>All resources in /ave/makler/*</web-resource-name>
<description>All resources in /ave/makler/*</description>
<url-pattern>/ave/makler/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>makler</role-name>
<role-name>maklerChef</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>jBossJaasHeimdiRealm</realm-name>
<form-login-config>
<form-login-page>/login/login.jsf</form-login-page>
<form-error-page>/login/loginFailed.jsf</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>makler</role-name>
</security-role>
<security-role>
<role-name>maklerChef</role-name>
</security-role>
<security-role>
<role-name>kaufer</role-name>
</security-role>
<session-config>
<cookie-config>
<http-only>true</http-only> <!-- https://owasp.org/www-community/HttpOnly , #see also: https://www.cookiepro.com/knowledge/httponly-cookie/ -->
<!-- <secure>true</secure> --> <!-- https://owasp.org/www-community/controls/SecureCookieAttribute -->
</cookie-config>
<session-timeout>1</session-timeout>
</session-config>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/error.faces</location>
</error-page>
<error-page>
<exception-type>javax.faces.FacesException</exception-type>
<location>/error.faces</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error.faces</location>
</error-page>
<!--
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/error.faces</location>
</error-page>
-->
</web-app>
Thank you

Just debug your Session issues with this SessionDebugListener...
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import lombok.extern.slf4j.Slf4j;
/**
* HttpSessionListener to monitor the creation and destruction of JSESSIONs.
*/
#Slf4j
public class SessionDebugListener implements HttpSessionListener {
#Override
public void sessionCreated(final HttpSessionEvent se) {
LOG.info("Session Created {}", se.getSession().getId());
}
#Override
public void sessionDestroyed(final HttpSessionEvent se) {
LOG.info("Session Destroyed {}", se.getSession().getId());
}
}
web.xml
<web-app ...>
<listener>
<listener-class>com.your.SessionDebugListener </listener-class>
</listener>
</web-app>
Here is a more advanced example: https://www.baeldung.com/httpsessionlistener_with_metrics

Related

RichFaces spacer gif URL wrong after upgrade to JBoss 8 (WildFly)

I'm doing an upgrade from JBoss 6 to JBoss 8 (WildFly). The version of RichFaces 3.3.3 has stayed the same. Several places in the code call the RichText spacer, like this:
<rich:spacer height="15" width="5"/>
In web.xml, the servlet-mapping entries related to Faces looked like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
When running JBoss 6, the spacer image had the following URL, which worked fine:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif
We start running into issues when we upgrade to JBoss 8. The URL suddenly looks like this, and returns a 404 Not Found when accessed:
https://host.com/dc/faces/a4j/g/3_3_3.Finalimages/spacer.gif
I tried removing all but the *.jsf servlet-mapping from web.xml, like the documentation specifies. This made the URL look like this:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf
The URL returns a 500 Internal Server Error when accessed:
ERROR [io.undertow.request] (default task-29) UT005023: Exception handling request to /dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf: javax.servlet.ServletException: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : images/spacer.gif.jsf
The image is always available the original URL.
For reference, here is web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>[clipped]</display-name>
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>mojarra-1.2_15</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.jboss.seam.core.init.debug</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>Disable MyFacesExtensionsFilter check</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>5</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
<param-value>5</param-value>
</context-param>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<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>*.jsf</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>45</session-timeout>
</session-config>
</web-app>
I just assume bypass the issue and do away with the spacer, but the spacer is also called internally by RichFaces, within some of the components that we are currently using.
What should I do to get the spacer to show up correctly?
You should exclude second initialization of org.ajax4jsf.Filter in filter and filter-mapping sections of web.xml. Seam instantiate org.ajax4jsf.Filter from Ajax4jsfFilterInstantiator class.
Please remove following code from web.xml
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
...
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
See related RichFaces Issue RF-3410

How to set JSF welcome file in Spring-MVC and JSF mixed web application

I am working on a web project that both Spring MVC 3.1.1 and Primefaces 3.4.2 are mixed together. Spring MVC is used to serve REST services(using URL annotations) and PrimeFaces is used for user interfaces. So naturally, I have one configuration file for both of these components.
Here is my problem:
index.xhtml is already set as welcome file in web.xml but I can't access the home page through http://localhost:8080/SampleWebApplication/
But I can access the home page through http://localhost:8080/SampleWebApplication/index.xhtml
What I want to achieve is I want to set index.xhtml file as the project's welcome file so that when the user enters http://localhost:8080/SampleWebApplication/ the user must be directed to the welcome page.
This is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/applicationContext.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<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>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
11
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
</web-app>
The welcome file request of / matches your Spring MVC servlet which is mapped on / and is therefore never hitting the JSF servlet which is mapped on *.xhtml.
You need to map your Spring MVC servlet on a more specific URL pattern. E.g. /rest/* or /api/* or whatever folder covers all those REST service resources. Once done that, the JSF servlet will be hit.

I cannot access my simple jsf project after deployement

I do not understand why I am getting 404 error while trying to access my application
my index.xhtml is in (Web Content)
In my log I have no error
I created my project using eclipse : web dynamic project :
my url :
http://localhost:8080/jsf_getting_started/
I tried with eclipse with tomcat (Run On Server).
My 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_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>jsf_getting_started</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<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>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
The problem is that you have set the mapping of the Faces Servlet as /faces/* so in order to access to your page and be parsed by this servlet you must access to it like
http://localhost:8080/jsf_getting_started/faces/index.xhtml
But the problem with the /faces/* configuration is that the Faces Servlet will even process non-JSF resources like images, JS, CSS scripts, etc.
The best solution would be to change the mapping to *.xhtml and remove all the pages in welcome file list to have only index.xhtml. Your web.xml file will look like this (note that I'm just posting the changes made on the parts described in this answer):
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<!-- no need of the other files... -->
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<!-- The relevant URL mapping when using Facelets and JSF -->
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
After changing the web.xml file, rebuild your project, make sure to undeploy it from Tomcat Server and try again.
You need to add index.xhtml in the welcome-file-list.

Remove faces servlet url pattern and page extension from url

i have a command link in my page which looks like:
<h:commandLink value="Add user" action="add?faces-redirect=true" />
and when i click it, it goes to url:
http://localhost:8080/myapp/faces/add.xhtml
but i want the url to be:
http://localhost:8080/myapp/add
how to do that ?
i am using spring 3, jsf 2
this is my 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>myapp</display-name>
<!-- Add Support for Spring -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<!-- Change to "Production" when you are ready to deploy -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>faces/users.xhtml</welcome-file>
</welcome-file-list>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
You can use PrettyFaces for it.

faces-redirect=true in JSF

I am using the ?faces-redirect=true in my JSF2, since I would like to redirect the user so the URL will be changed.
In JSF1.2 I added </redirect> in faces-config.
In JSF2 I have to add to my url return home?faces-redirect=true.
The problem is that I see faces-redirect=2 in the URL, what I haven't seen in JSF1.2 when I used </redirect>
How can I use faces-redirect in actions without displaying it in the browser URL?
My Jar's list:
antlr-2.7.6.jar
aopalliance-1.0.jar
aspectjrt.jar
atmosphere-compat-tomcat-0.5.jar
atmosphere-runtime-0.5.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-dbcp-1.2.2.jar
commons-digester-2.0.jar
commons-fileupload-1.2.1.jar
commons-httpclient-3.1.jar
commons-io-1.4.jar
commons-logging-1.1.1.jar
commons-pool-1.5.4.jar
dom4j.jar
ehcache-1.2.4.jar
hibernate-annotations.jar
hibernate-cglib-repack-2.1_3.jar
hibernate-commons-annotations.jar
hibernate3.jar
itext-1.4.8.jar
javassist.jar
javax.persistence.jar
jhighlight-1.0.jar
jsf-api.jar
jsf-impl.jar
jstl-api-1.2.jar
jstl-impl-1.2.jar
jta-1.1.jar
log4j-1.2.15.jar
mail.jar
mysql-connector-java-5.1.0-bin.jar
org.springframework.aop-3.0.1.RELEASE-A.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.aspects-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.jar
org.springframework.context.support-3.0.1.RELEASE-A.jar
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE-A.jar
org.springframework.instrument-3.0.1.RELEASE-A.jar
org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar
org.springframework.jdbc-3.0.1.RELEASE-A.jar
org.springframework.jms-3.0.1.RELEASE-A.jar
org.springframework.orm-3.0.1.RELEASE-A.jar
org.springframework.oxm-3.0.1.RELEASE-A.jar
org.springframework.test-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEASE-A.jar
org.springframework.web-3.0.1.RELEASE-A.jar
org.springframework.web.portlet-3.0.1.RELEASE-A.jar
org.springframework.web.servlet-3.0.1.RELEASE-A.jar
org.springframework.web.struts-3.0.1.RELEASE-A.jar
poi-3.2-FINAL.jar
primefaces-2.0.3-SNAPSHOT.jar
slf4j-api-1.5.11.jar
slf4j-log4j12-1.5.11.jar
spring-aop.jar
My 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>OnBoard</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<description></description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext.xml
classpath:/applicationContext-security.xml
</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>com.sun.faces.forceLoadConfiguration</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
<param-value>false</param-value>
</context-param>
<filter>
<filter-name>Security Page Filter</filter-name>
<filter-class>com.mycompany.servlet.SecurityFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Security Page Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
This looks all fine. Something else is disturbing it. Maybe Spring? I don't do Spring so I can't tell anything about it. At least, it works fine here with Mojarra 2.0.2 + PrimeFaces 2.1 + Tomcat 6.0.24.
To nail this problem down anyway, consider creating a brand new web project with only jsf-api.jar and jsf-impl.jar files in the /WEB-INF/lib and two simple XHTML files with a <h:commandButton outcome="otherfile?faces-redirect=true" />. Then add libraries/components/mappings step by step until you get the same setup as the original project. Test the working of faces-redirect during every step. Keep track of what you've added so that you know what may have caused this problem.
That's not what I'm experiencing with Mojarra (the RI). If I return the following in a managed bean:
return "somepage" + "?faces-redirect=true";
JSF redirects to the target somepage view and the URL doesn't include the ?faces-redirect=true.
What implementation are you using?

Resources