primefaces file upload not working - jsf

I have the following code, running on jboss eap 6.1:
<h:form id="SatelliteListForm" enctype="multipart/form-data">
...
<p:fileUpload id="datamodelImport" mode="advanced" auto="true" disabled="#{empty satelliteController.selected}" fileUploadListener="#{satelliteController.importDatamodel}" update=":messages" allowTypes="/(\.|\/)(csv)$/"/>
web.xml contains this:
<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>
pom.xml have this:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
the problem? it doesn't not work. The UI seems to be working fine, but the file upload listener is not called.
Using search BalucC suggest to debug http communication. Done, it is not the browser fault. Then he suggest to debug the decode method of the corresponding primefaces class. Done. In the following class
org.primefaces.component.fileupload.CommonsFileUploadDecoder
he do this check:
if(multipartRequest != null) // keep going, otherwise stop
in my case that variable is null. I can't understand why. The generated html code correctly contains the enctype.
BalusC suggest that something could happen during request processing. I'm using atmosphere, but it uses another servlet to communicate. Also he is complaining for quite some time about comet support (someday I will fix that). Don't know if it matters.
What else can I check?
It's irritating that something so simple as file upload is wasting so much of my time...
Thank you for your time.

did you try to add the following parameter to your web.xml?
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
I had the same behaviour until I added these context param
Regards
Michael

Related

javax.faces.webapp.FacesServlet is not assignable to javax.servlet.Servlet , jakarta.servlet.Servlet

I tried to set up a JSF project in Intellij. I noticed that the JSF components are not being rendered, so I started checking the things listed in this post. Here 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">
<welcome-file-list>
<welcome-file>faces/home.xhtml</welcome-file>
</welcome-file-list>
<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>
...
</web-app>
My project compiles but IntelliJ highlights the servlet:
I also include jsf in my pom.xml, in case that is relevant:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.20</version>
<scope>provided</scope>
</dependency>
Any idea what the problem here could be?
In my case I forgot to write:
extends jakarta.servlet.http.HttpServlet
For a class in my .java file.

How to use the Push of Primefaces 5 with GlassFish 4.0?

I create an example on eclipse to use push of primefaces 5 with glassfish 4.0. I copy code of primefaces's push (http://www.primefaces.org/showcase/push/chat.xhtml). I configuration in pom.xml like bellow:
pom.xml
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Faces Implementation -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Faces Library -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Primefaces Version 5 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<!-- Atmosphere -->
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<!-- File Upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
<!-- JSP Library -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- JSTL Library -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
and for web.xml:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
<!-- Following param only needed for MyFaces (TomEE, etc) -->
<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>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
After I finish all code like primefaces's push and deploy directly from eclipse to glassfish 4 and have error like bellow:
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Lorg/primefaces/push/EventBus;.
Please help me to find out the issue and deploy successful.
I'm a newbie in PFP/Atmosphere but for me it seems like the atmosphere API is missing. And since I've struggled a lot on making Primefaces 5.1 Push to work on Glassfish 4 I would like to share my setup with the community :)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>MyProject</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
<!-- **************** FACES CONFIGURATION ******************** -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- **************** Primefaces PUSH (Athmosphere based) ******************** -->
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
<!-- **************** Primefaces FILE UPLOAD ******************** -->
<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>
<!-- ********* PARTIAL SUBMIT <ENABLED> ********* -->
<context-param>
<param-name>primefaces.SUBMIT</param-name>
<param-value>partial</param-value>
</context-param>
<!-- ********* CLIENT_SIDE_VALIDATION <ENABLED> ********* -->
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
<!-- ********* FACELETS_SKIP_COMMENTS <ENABLED> ********* -->
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>auto</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
</web-app>
My library setup is as follows: WEB-INF/lib/
-primefaces-5.1.jar
-vaadin-slf4j-jdk14-1.6.1.jar
-atmosphere-runtime-2.2.4.vaadin5.jar
-slf4j-api-1.7.10.jar
-commons-fileupload-1.3.1.jar
Note: I'm using Luna Service Release 1a (4.4.1) and I've found out that when I change my setup I have to remove my App from the Server, reboot the server, redeploy and Project->clean in order to make it work.
Hope this post can help.

JSF Mapping with Maven - starting using maven

hope you had a great day
For a few days I am trying to learn using Maven - cause I have heard that its good practice to create my projects with it.
And so what I did. Maven is quite difficult for my present abilities. Now I am trying to create JSF page and 've got problem with mapping. Maven has created a simple web.xml for me, its almost empty (it has just tag and its closed too). I have added JSF depenedency and made simple a.xhtml page with one button and text field. If I run it, it works fine. But If I enter some changes in web.xml - I would add mapping for *.jsf *.faces *.xhtml etc. it wont work anymore. I am sick about it, have no idea how to fix it.
Here is my present code:
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.maciej</groupId>
<artifactId>Mejwn</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Mejwn Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>Mejwn</finalName>
</build>
</project>
web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
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">
<welcome-file-list>
<welcome-file>a.xhtml</welcome-file>
</welcome-file-list>
<display-name>Archetype Created Web Application</display-name>
<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>
<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>
My project structure:
http://imagizer.imageshack.us/v2/800x600q90/13/qr18.jpg
(I cant add images, too low reputation for now:P)
Hope you can help me!
Thanks! ;)
Wow, I have fixed it. The problem was in pom.xml, I had to add those dependencies:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>
And all mappings and rendering JSF components(which hasnt been working as well) are fine now
Thanks and have a good day

Primefaces FileUpload event not firing - JSF 2.0

I have posted my question on the Primefaces forum but no one has responded so I figured I would try here.
I have been attempting to get fileUpload to work for some time now. I am currently running the RC2 build with mojarra 2.0.3 and Tomcat 7.
I have a dialog which will contain the fileUpload component like so.
<p:dialog id="uploadFileDialog" >
<h:form id="uplaodFileForm" prependId="false" enctype="multipart/form-data">
<p:fileUpload fileUploadListener="#{fileUploadController.uploadFile} auto="true"/>
</h:form>
</p:dialog>
The fileUploadController looks like this
public class FileUploadController {
public void uploadFile(FileUploadEvent event) {
byte[] file = event.getFile().getContents();
System.out.println("MADE IT INTO FILE UPLOAD !!! ");
}
}
For some reason when the file is uploaded it never triggers the fileUploadEvent and it never gets into the controller. The upload looks like its working, the flash part renders and gives the impression its doing something but no backing bean is ever being called. I can seem to figure out what I am doing wrong and I have read just about every post on uploading a file using primefaces. Anyone know what I am doing wrong?
java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream
PrimeFaces fileupload uses Apache Commons FileUpload under the covers which in turn has another dependency, the Apache Commons IO. Ensure that you've both JAR's in your /WEB-INF/lib.
Update: as per the comments, you also need to ensure that the upload filter is been declared in web.xml as per the users' guide:
<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>
And you also need to ensure that there are no other filters before in the web.xml which may be reading the HttpServletRequest#getInputStream(), because it can be read only once.
I have also experienced a similar problem. The fix for me (using a Maven project) was to add the following dependencies in the pom.xml file:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
This is the equivalent of having the corresponding .jar files in your WEB-INF/lib, so try do that if this is not a Maven project.
that is correct you must add
<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>
AND later this
<!-- 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>*.jsf</url-pattern>
</servlet-mapping>
aditionaly if your using maven add this dependencies
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>portlet-api</groupId>
<artifactId>portlet-api</artifactId>
<version>1.0</version>
</dependency>
i think i have solved your problem.
Check on your web.xml the presence of:
<context-param>
<param-name>com.sun.faces.enableViewStateIdRendering</param-name>
<param-value>false</param-value>
</context-param>
You must delete this option or set it do True (the default value).
I have the same issue, I have solved it by adding
<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>
like BalusC said.
but adding this :
<!-- 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>*.jsf</url-pattern>
</servlet-mapping>
Because by default in J2EE 6 this part is optional JSF 2.0 Servlet activates automatically when the WEB-INF/faces-config.xml descriptor is present.
But it necessary to active correctly PrimeFaces Filter
Jboss 6.1.0.Final / PrimeFaces 3.0.RC2
In Websphere 7 the event is fired because when I select file and press upload I can see bar to upload that grow up.
The problem is that in Websphere 7 I suppose that there are a filter that consume HttpRequest and when arrive to event listener is just consumed so don't have data :(
No message are present in log the debugging is very complicate. Exists some trace or logger to enable in JSF 2 Mojarra 2 and PrimeFaces 3.4.2?

Primefaces p:fileupload component problem

I am using Primefaces 2.0.1 but the FileUpload component is not working properly. It uses JQuery uploadify behind the scenes. This is my web.xml
<?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">
<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>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
</web-app>
This is my index.xhtml :-
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form prependId="false">
<h:commandButton actionListener="#{NewJSFManagedBean.add}" value="add"/>
<p:fileUpload auto="false" widgetVar="fileUpl" fileUploadListener="#{NewJSFManagedBean.saveFile}"/>
</h:form>
</h:body>
</html>
I have following libraries in my classpath :-
primefaces 2.0.1
commons-beanutils
commons-beanutils-bean-collection
commons-digestor
commons-fileUpload
commons-io
commons-logging
jhighlight
The file gets correctly uploaded in /tmp but in browser it always says HTTP error. Please help me. It used to work till yesterday. But today i did a fresh installation of Glassfish and it has stopped working.
A filter needs to be added to web.xml. So, add these lines to web.xml
<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>51200</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/tmp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
To be able to use the Primefaces fileUpload component, a few Apache Commons dependencies also need to be added:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
I have had some troubles with this component also. I seem to remember that by adding an id to the fileUpload component and/or the form, things started working for me. Worth a try.
i think you are missing enctype="multipart/form-data" in your h:form tag.
I had the same problem. And note that by deleting the cookies from my browser-firefox-and going to upload my application and it worked.
I'm using PRIMEFACES 2.2.1 and the problem is still there: HTTP error when Chrome or Firefox is used; all fine with IE. In my case, this apparently happens due to a reverse proxy shielding the actual server running the application. If the application is used through a direct URL reference (http://server:port/some path), it works fine; if the reverse proxy URL is used, the requests fail. I don't know why this fails in FF and GC and doesn't do so in IE.

Resources