title: handleFileUpload not called
body: <p>Having a weird issue with my file upload</p>
  
  <p>handleFileUpload is never called, and in the xhtml file it underlines this with yellow and says unkown  property </p>
  
  <p>here is my web.xml</p>
  
  <pre><code>&lt;context-param&gt;
          &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
          &lt;param-value&gt;server&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;/filter-mapping&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
  </code></pre>
  
  <p>my file upload controller, i have gone back to see if i can call the most basic version, but currently it is not </p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package richard.fileupload;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import javax.annotation.PostConstruct;
  import javax.faces.application.FacesMessage;
  import javax.faces.context.FacesContext;
  import javax.faces.event.ActionEvent;
  import javax.faces.application.FacesMessage;
  import javax.faces.bean.ManagedBean;
  import javax.faces.context.FacesContext;
  
  import org.primefaces.event.FileUploadEvent;
  
  @ManagedBean(name = "fileUploadController")
  public class FileUploadController {
  
  
       public void handleFileUpload(FileUploadEvent event) {
       System.out.println("called");
       FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
       FacesContext.getCurrentInstance().addMessage(null, msg);
       }
       }
        /*
      private String username;
  
      @PostConstruct
      public void init() {
          System.out.println("called get username");
          username = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
      }
      private String destination = "C:/Users/Richard/printing~subversion/fileupload/web/WEB-INF/uploaded/"; // main location for uploads
      File theFile = new File(destination + username); // will create a sub folder for each user (currently does not work, below hopefully is a solution) 
  
      public File getDirectory(String destination, String username) {
               System.out.println("called get directory");
          // currently not working, is not calling the username or destination 
          //set the user directory from the destinarion and the logged user name
          File directory = new File(destination, username);
          //check if the location exists
          if (!directory.exists()) {
              //let's try to create it
              try {
                  directory.mkdir();
              } catch (SecurityException secEx) {
                  //handle the exception
                  secEx.printStackTrace(System.out);
                  directory = null;
              }
          }
          return directory;
      }
  
      public void handleFileUpload(FileUploadEvent event) {
               System.out.println("called handle file");
          FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
          FacesContext.getCurrentInstance().addMessage(null, msg);
          try {
              copyFile(event.getFile().getFileName(), event.getFile().getInputstream());
          } catch (IOException e) {
              //handle the exception
              e.printStackTrace();
          }
      }
  
      public void copyFile(String fileName, InputStream in) {
          try {
  
  
              // write the inputStream to a FileOutputStream
              OutputStream out = new FileOutputStream(new File(theFile + "/" + fileName)); // cannot find path when adding username atm
              System.out.println(theFile); //testing 
  
              int read = 0;
              byte[] bytes = new byte[1024];
  
              while ((read = in.read(bytes)) != -1) {
                  out.write(bytes, 0, read);
              }
  
              in.close();
              out.flush();
              out.close();
  //make sure new file is created, (displays in glassfish server console not to end user)
              System.out.println("New file created!");
          } catch (IOException e) {
              System.out.println(e.getMessage());
          }
      }
  }
  */
  </code></pre>
  
  <p>here is my uploadText.xhtml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui"
        xmlns:corejsf="http://corejsf.com"&gt; 
      &lt;h:outputStylesheet name="css/testcss.css" /&gt;
      &lt;h:head&gt;
          &lt;title&gt;Print to Uni&lt;/title&gt;
          &lt;meta http-equiv="content-type" content="text/html; charset=windows-1252" /&gt;
          &lt;!-- &lt;link rel="stylesheet" type="text/css" href="style.css" title="style" /&gt; --&gt;
      &lt;/h:head&gt;
      &lt;body&gt;
          &lt;div id="main"&gt;
              &lt;div id="header"&gt;
  
                  &lt;div id="logo"&gt;
                      &lt;div id="logo_text"&gt;
                          &lt;h1&gt;&lt;a href="/GUI/index.xhtml"&gt;Remote&lt;span class="logo_colour"&gt;Printing&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;
                          &lt;h2&gt;This is a web app that allows users to print to University&lt;/h2&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
      &lt;div id="site_content"&gt;
          &lt;div id="content"&gt;
              &lt;h:body&gt;
                  &lt;h:form enctype="multipart/form-data"&gt;
                      Upload a text file:
                      &lt;h:form&gt;
                          &lt;!--&lt;p:growl id="messages" showSummary="true" showDetail="true" /&gt; --&gt;
                          &lt;br&gt;&lt;/br&gt;
                          &lt;br&gt;&lt;/br&gt;
  
                          &lt;p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
                                        mode="advanced" 
                                        update="messages"
                                        sizeLimit="100000000" 
                                        allowTypes="/(\.|\/)(gif|jpe?g|png|doc|docx|txt|pdf)$/"
                                        auto="true"/&gt;
                          &lt;p:growl id="messages" showDetail="true"/&gt;
                      &lt;/h:form&gt;
                      &lt;br&gt;&lt;/br&gt;
                      &lt;br&gt;&lt;/br&gt;
                      &lt;p:commandButton value="Submit" action="/GUI/submittedText" icon ="ui-icon-arrowstop-1-n"/&gt;
                      &lt;div class="divider"/&gt;
                      &lt;p:commandButton  value="Homepage" action="#{userBean.buttonHome}" icon="ui-icon-home"/&gt;   
                  &lt;/h:form&gt;
              &lt;/h:body&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>i have both commons files that are needed in my libraries, what is causing this ? i did have it working but did not back up the changes and now it does not work</p>