"Error 500: com.ocpsoft.pretty.PrettyFilter incompatible with javax.servlet.Filter"
JSF2.1.2
Prettyfaces-jsf2-3.3.2
Primefaces 3.2
WebSphere Application Server 7.0.0.9
Tried with adding custom properties in WebSphere admin console for filter compatibility(Last in FAQ at http://ocpsoft.org/prettyfaces/).
Tomcat 6.0.32 don't have any issues but once deployed the app in WAS got the issue.
Below is webxml
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>3</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
<param-value>10</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:WEB-INF/Controller-servlet.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>
<description>JSF Injection provider</description>
<param-name>com.sun.faces.injectionProvider</param-name>
<param-value>net.devgrok.jsf.Tomcat6GuiceInjectionProvider</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
<param-value>abc.xhtml</param-value>
</context-param>
<!-- JSF Required Context Params END-->
<!-- JSF Required Filters & Listeners START-->
<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>1048576000</param-value><!--51200-->
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/temp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</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>
</filter-mapping>
<!-- JSF Required Filters & Listeners END-->
<!-- JSF Required Servlets START -->
<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>
Changed war class loader order to "parent last" and policy to "Single class loader for application" in WebSphere admin console to pick apps own JSF version.
Removed the redundant jars (servlet-api.jar and xml-apis-1.0.b2.jar are in my case) from WEB-INF/Lib folder as it collides with server versions.
The above solved this issue. However creating Isolated shared library (https://stackoverflow.com/a/12081307/1341062) would be better option when you have app-specific dependencies that may collide with server versions.
Related
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
I've been trying to set up OCPsoft's Rewrite http://ocpsoft.org/rewrite/examples/ for JSF 2.2.
My setup:
JSF 2.2
Tomcat 7
Servlet Container 3.0
Maven Project
URLRewrite Version 2.0.12
My pom.xml includes the following two dependencies
<!-- for JSF 2.x -->
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>2.0.12.Final</version>
</dependency>
I have placed a pretty-config.xml in my WEB-INF folder
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">
<url-mapping id="test">
<pattern value="/test" />
<view-id value="/home/index.jsf" />
</url-mapping>
</pretty-config>
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>myproject</display-name>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
<param-value>primefaces:jquery/jquery.js=http://code.jquery.com/jquery-1.11.0.min.js</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.2. Zur Produktion wieder auf server schalten. HTTP
GET Request zusammen mit 'client'
führen zum Verlust des STATE</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<description>Next step - disable compression of state in server</description>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that
it is "human readable". i.e. additional line separators and whitespace will
be written, that do not influence
the HTML code. Default: "true"</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Very important, too, is to disable the serialization
of state, serialization and deserialization of the component tree is a
major
performance hit
</description>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<!-- Verschlüsselung des Viewstates -->
<context-param>
<param-name>org.apache.myfaces.secret</param-name>
<param-value>NzY1NDMyMTA=</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>3</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
<param-value>10</param-value>
</context-param>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error/404.jsf</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/home/index.jsf</location>
</error-page>
<filter>
<filter-name>adminPinFilter</filter-name>
<filter-class>com.myproject.filters.AdminPinFilter</filter-class>
</filter>
<filter>
<filter-name>facesRedirectFilter</filter-name>
<filter-class>com.myproject.filters.FacesRedirectFilter</filter-class>
<init-param>
<description>Auf diese Extension soll nicht direkt zugegriffen
werden
(z.B. .xhtml)</description>
<param-name>forbiddenExtension</param-name>
<param-value>.xhtml</param-value>
</init-param>
<init-param>
<description>Auf diese Extension soll umgeleitet werden (z.B. .jsf)</description>
<param-name>redirectExtension</param-name>
<param-value>.jsf</param-value>
</init-param>
</filter>
<filter>
<filter-name>directGetFilter</filter-name>
<filter-class>com.myproject.filters.DirectGetFilter</filter-class>
</filter>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter>
<filter-name>sessionFilter</filter-name>
<filter-class>com.myproject.filters.SessionFilter</filter-class>
</filter>
<filter>
<filter-name>authFilter</filter-name>
<filter-class>com.myproject.filters.AuthFilter</filter-class>
</filter>
<filter>
<filter-name>offerFilter</filter-name>
<filter-class>com.myproject.filters.OfferFilter</filter-class>
</filter>
<filter>
<filter-name>adminAuthFilter</filter-name>
<filter-class>com.myproject.filters.AdminAuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>adminPinFilter</filter-name>
<url-pattern>/adminPin/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>facesRedirectFilter</filter-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sessionFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>authFilter</filter-name>
<url-pattern>/profile/*</url-pattern>
<url-pattern>/conversation/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>adminAuthFilter</filter-name>
<url-pattern>/admin/panel/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>offerFilter</filter-name>
<url-pattern>/offer/view/*</url-pattern>
</filter-mapping>
<session-config>
<!-- Disables URL-based sessions (no more 'jsessionid' in the URL using
Tomcat) -->
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<listener>
<listener-class>com.myproject.system.ContextFinalizer</listener-class>
</listener>
</web-app>
However, if I navigate to /test, I'm only getting a 404 error.
Is there anything I missed?
Do you have a file in your web application called "/home/index.xhtml" (or something to that effect)? Please also post your web.xml if possible. Thanks!
Also, it seems that you have quite a few filters defined in your web.xml, but you do not define the rewrite filter. This should be fine, however, it is worth adding the filter manually and seeing what happens. The rewrite filter should be the first filter in your web.xml:
<listener>
<listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletRequestListener</listener-class>
</listener>
<listener>
<listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener</listener-class>
</listener>
<filter>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ASYNC</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
Everything is working fine now. I removed the default servlet from my web.xml.
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
I am using <rich:fileUpload> of RichFaces 3.3.3 Final. When I upload some Excel files in Chrome browser, then it sometimes shows the "Transfer failed" error message as in below screenshot:
Sample Code,
<rich:fileUpload id="fileUpload" addControlLabel="#{bundle.browse}"
allowFlash="#{not TestFileUpload.allow}"
fileUploadListener="#{TestFileUpload.fileUploadListener}"
maxFilesQuantity="10"
autoclear="false"
listHeight="135px;"
uploadControlLabel="#{bundle.upload}"
progressLabel="#{bundle.progress}"
sizeErrorLabel="#{bundle.sizeError}"
noDuplicate="true"
style="width: 100%; height: 135px;">
<a4j:support event="onuploadcomplete"
onbeforedomupdate=""
action="#{TestFileUpload.validateExcel}"
reRender="validationDetailPanelId, messageId"
focus="cancelId"/>
</rich:fileUpload>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
<param-value>true</param-value>
</context-param>
<!--Configuration for Facelets-->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
<context-param>
<param-name>
facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE
</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>all</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>all</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>Wine</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/test/faces-config.xml
</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>Ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
<init-param>
<param-name>enable-cache</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>createTempFiles</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxRequestSize</param-name>
<param-value>1048576</param-value>
</init-param>
</filter>
<filter>
<filter-name>SFilter</filter-name>
<filter-class>com.test.SFilter</filter-class>
</filter>
<listener>
<display-name>SLCListener</display-name>
<listener-class>com.test.SLCListener</listener-class>
</listener>
<!-- End of Rich Faces and A4JSF -->
<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>Custom Faces Servlet</servlet-name>
<servlet-class>com.test.CFServlet</servlet-class>
<init-param>
<param-name>error</param-name>
<param-value>/faces/pages/errorPage.jsp</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>ASServlet</servlet-name>
<servlet-class>com.test.ASServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>PASRServlet</servlet-name>
<servlet-class>com.test.PASRServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>LOServlet</servlet-name>
<servlet-class>com.test.LOServlet</servlet-class>
<init-param>
<param-name>DException</param-name>
<param-value>/faces/pages/dException.jsp</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>FDServlet</servlet-name>
<servlet-class>com.test.FDServlet</servlet-class>
</servlet>
<!--OverRiding FacesServlet Start-->
<servlet-mapping>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<!--Filter for ajaxrequest and Custom Faces Servlet-->
<filter-mapping>
<filter-name>Ajax4jsf</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>SSEFilter</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<!--End-->
<!-- Filter for Commons File Upload -->
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
</filter-mapping>
<!-- End of commons file upload filter -->
<error-page>
<error-code>404</error-code>
<location>/faces/pages/error/errorPage.jsp</location>
</error-page>
</web-app>
The file is also not being uploaded to the server. How is this caused and how can I solve it?
i have the same problem since one of the lastest update of Chrome.
Chrome version : 36
The fileUploadListener method in the bean is called twice when you click on the upload button.
The debug mode reveals that The second time, the file is lost.
I bypassed the problem like that :
public void fileUploadListener(UploadEvent event) {
if(!event.getUploadItem().getFileName().equalsIgnoreCase("")){
//code here
}
}
First make your bean session scope then in web.xml change boolean attribute of createTempFiles to false instead of true just as below:
<init-param>
<param-name>createTempFiles</param-name>
<param-value>false</param-value>
</init-param>
I am migrating my application from jsf 1.2 to 2.0 and i have followed this url for migrating http://www.ibm.com/developerworks/rational/library/java-server-faces-migration/
But when deploying in weblogic server I am facing the following issue
[HTTP:101216]Servlet: "Faces Servlet" failed to preload on startup in Web application: " customer- web". java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804) at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:306) at javax.faces.webapp.FacesServlet.init(FacesServlet.java:166) at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64) at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:48) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:531) at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1915) at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1889) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1807) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3045) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1397) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409) at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:54) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
My web.xml is
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5">
<display-name>Customer Web</display-name>
<!-- The master configuration file for this Spring web application -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/web-application-config.xml
</param-value>
</context-param>
<!-- Faces configuration -->
<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces-config.xml,
/WEB-INF/project-faces-config.xml
</param-value>
</context-param>
<!-- Tag libs for facelets -->
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>
/WEB-INF/facelets.taglib.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Enables special Facelets debug output during development -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<!-- Enforce UTF-8 Character Encoding -->
<filter>
<filter-name>charEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Enables Spring Security -->
<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>
</filter-mapping>
<!-- Loads the Spring web application context -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- <listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener> -->
<!-- For spring-managed request- and session-scoped beans -->
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Serves static resource content from .jar files such as spring-faces.jar -->
<servlet>
<servlet-name>Resources Servlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Map all /resources requests to the Resource Servlet for handling -->
<servlet-mapping>
<servlet-name>Resources Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Map all /pages requests to the Dispatcher Servlet for handling -->
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/pages/*</url-pattern>
</servlet-mapping>
<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Just here so the JSF implementation can initialize -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/pages/error</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/pages/accessDenied</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/pages/error</location>
</error-page>
</web-app>
Please check that the jsf-api-2.x.y.jar (and maybe other JSF 2.0 dependencies) is in the CLASSPATH.
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?