Board index JavaServer Faces General Fileupload Component not working

Fileupload Component not working

Components, Ajax Framework, Utilities and More.

Posts: 11
anybody help me i serve a lot but did not find any solution about file upload component
i am using simple fileupload component from ... Simple.jsf
my abc.xhtml page is
<h:form enctype="multipart/form-data">

<p:messages showDetail="true"/>

<p:fileUpload value="#{test.file}" mode="simple"/>

<p:commandButton value="Submit" ajax="false"

my bean is with session scop
and i am using primefaces.3.0.M3 version

private UploadedFile file;

public UploadedFile getFile() {
return file;

public void setFile(UploadedFile file) {
this.file = file;
public String upload() {
System.out.println("calling upload");
FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}catch(Exception e){
System.out.println("calling upload "+ e.getMessage());
return null;
show Nullpointer Exception
because file object not setted when submit button press
kindly anybody tell me what is going wrong in the above code or is there any additional code is required

Posts: 9
U need 2 mores libs (commons-fileupload-1.1.jar and commons-io-1.4.jar) and add this code in your web.xml...

        <filter-name>PrimeFaces FileUpload Filter</filter-name> 
        <filter-class> org.primefaces.webapp.filter.FileUploadFilter</filter-class> 
        <filter-name>PrimeFaces FileUpload Filter</filter-name> 
        <servlet-name>Faces Servlet</servlet-name> 

(i'm sorry for my english)

Posts: 11
thanks iurimatos for quick response but i have also added the below code in web.xml and added both of jar in my lib but nothing happen

Return to General