title: Primefaces Mobile p:fileupload upload method not called
body: <p>I am working on a web application for mobile devices where a user can upload a file (image) on several occasions.</p>
  <p>Since I am using the Primefaces mobile renderkit, I have to use Primefaces' simple <code>p:fileupload</code>without ajax.</p>
  <p>The Problem:
  When I want to upload an Image I can select the file (components are rendered correctly) and then hit the &quot;Upload&quot; button. After I hit &quot;Upload&quot;, the page refreshes but <code>myBean.saveImage()</code> is never called. <code>myBean.fileUploadController.setFile</code> isn't called either. I don't get any error messages in the Netbeans console and neither in Chromes JS Console.</p>
  <p>So far I tried to use the native HTTP Servlet Upload which is supported by primefaces since version 5.0 and the old commons.fileupload way - same result.</p>
  <p>I followed <a href="https://stackoverflow.com/a/8880083/2703623">this great guide</a> to troubleshoot <code>p:fileupload</code>but I still get the same result after doing everything suggested in the guide.</p>
  <p>I created a fileuploadtest.xhtml page to test the upload functionality which looks like this:</p>
  <pre><code>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;
      xmlns:f=&quot;http://java.sun.com/jsf/core&quot;
      xmlns:p=&quot;http://primefaces.org/ui&quot;
      xmlns:pm=&quot;http://primefaces.org/mobile&quot;&gt;
       
      &lt;f:view renderKitId=&quot;PRIMEFACES_MOBILE&quot; /&gt;
       
      &lt;h:head&gt;
   
      &lt;/h:head&gt;
       
      &lt;h:body&gt;
           
          &lt;pm:page&gt;
              &lt;pm:header title=&quot;Title&quot;&gt;&lt;/pm:header&gt;
               
              &lt;pm:content&gt;
                  &lt;h:form enctype=&quot;multipart/form-data&quot;&gt;
                      &lt;p:fileUpload value=&quot;#{myBean.fileUploadController.file}&quot; mode=&quot;simple&quot;/&gt;
                      &lt;p:commandButton value=&quot;Upload&quot; ajax=&quot;false&quot; action=&quot;#{myBean.saveImage}&quot;/&gt;
                  &lt;/h:form&gt;
              &lt;/pm:content&gt;
   
              &lt;pm:footer title=&quot;Footer&quot;&gt;&lt;/pm:footer&gt;
          &lt;/pm:page&gt;
      &lt;/h:body&gt;
       
  &lt;/html&gt;
  </code></pre>
  <p>Here is my bean and my <code>FileUploadController</code> class:</p>
  <p>MyBean.java:</p>
  <pre><code>    @Component
      @Scope(&quot;session&quot;)
      @Named
      public class MyBean implements Serializable {
      
          @Autowired(required = true)
          private FileUploadController fileUploadController;
      
          //Bunch of unrelated methods
      
          public void saveImage() {
               this.fileUploadController.upload();
               //some more code after upload() is complete
          }
          //getters&amp;setters
      }
  </code></pre>
  <p>FileUploadController.java:</p>
  <pre><code>@Component
  @Scope(&quot;session&quot;)
  public class FileUploadController {
  
      private UploadedFile file;
      
      public boolean upload() {
          if (file != null) {
              //upload here
              return true;
          } else {
              return false;
          }
      }
  
      public UploadedFile getFile() {
          return file;
      }
  
      public void setFile(UploadedFile file) {
          this.file = file;
      }
  }
  </code></pre>
  <p>Here is my web.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;web-app version=&quot;3.0&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
           xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot;&gt;
          
      &lt;description&gt;Webflow Archetype&lt;/description&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath*:/spring/applicationContext.xml,/WEB-INF/config/web-application-config.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;!-- Causes Facelets to refresh templates during development --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.FACELETS_REFRESH_PERIOD&lt;/param-name&gt;
          &lt;param-value&gt;1&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;com.sun.faces.expressionFactory&lt;/param-name&gt;
          &lt;param-value&gt;org.jboss.el.ExpressionFactoryImpl&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;com.sun.faces.sendPoweredByHeader&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;primefaces.THEME&lt;/param-name&gt;
          &lt;param-value&gt;cupertino&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;primefaces.FONT_AWESOME&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;description&gt;Define partial state saving as true/false.&lt;/description&gt;
          &lt;param-name&gt;javax.faces.PARTIAL_STATE_SAVING_METHOD&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Custom MarqueeComponent --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.FACELETS_LIBRARIES&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/marquee-taglib.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;BootsFaces_USETHEME&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;
  
  
    
  
      &lt;filter&gt;
          &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;encoding&lt;/param-name&gt;
              &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/ *&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;!-- Allows Jetty to serve Faces applications --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;com.sun.faces.config.ConfigureListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
   
  
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/ *&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      
      &lt;context-param&gt;
          &lt;param-name&gt;primefaces.UPLOADER&lt;/param-name&gt;
          &lt;param-value&gt;commons&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;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
      &lt;/filter-mapping&gt;
     
      &lt;session-config&gt;
          &lt;session-timeout&gt;180&lt;/session-timeout&gt;
          &lt;cookie-config&gt;
              &lt;secure&gt;true&lt;/secure&gt;
          &lt;/cookie-config&gt;
      &lt;/session-config&gt;
      
     
      
      &lt;servlet&gt;
          &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value/&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
          &lt;multipart-config&gt;
              &lt;max-file-size&gt;10485760&lt;/max-file-size&gt;
              &lt;max-request-size&gt;20971520&lt;/max-request-size&gt;
              &lt;file-size-threshold&gt;5242880&lt;/file-size-threshold&gt;
          &lt;/multipart-config&gt;
      &lt;/servlet&gt;
      &lt;!-- Map all /spring requests to the Dispatcher Servlet for handling --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey Spring Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;at.managementpartners.icosysmobile.rest&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
      
      &lt;!-- &lt;servlet&gt;
          &lt;servlet-name&gt;GetClientHostnameServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;at.managementpartners.icosysmobile.web.util.GetClientHostnameServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt; --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;FileServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;at.managementpartners.icosysmobile.web.util.FileServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
     
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/spring/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
    
      &lt;!-- Faces Servlet --&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;load-on-startup&gt;1&lt;/load-on-startup&gt; 
          &lt;multipart-config&gt;
              &lt;max-file-size&gt;10485760&lt;/max-file-size&gt;
              &lt;max-request-size&gt;20971520&lt;/max-request-size&gt;
              &lt;file-size-threshold&gt;5242880&lt;/file-size-threshold&gt;
          &lt;/multipart-config&gt;
      &lt;/servlet&gt;
      &lt;!-- Faces Servlet Mapping --&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/javax.faces.resource/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/faces/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/do/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;!--servlet&gt;
          &lt;servlet-name&gt;Primefaces Resource Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
              org.primefaces.resource.ResourceServlet
          &lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Primefaces Resource Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/primefaces_resource/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping--&gt;
      &lt;!-- Welcome files --&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Spring Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey Spring Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;FileServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/files/ *&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
    
      &lt;jsp-config&gt;
          &lt;jsp-property-group&gt;
              &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
              &lt;trim-directive-whitespaces&gt;false&lt;/trim-directive-whitespaces&gt;
          &lt;/jsp-property-group&gt;
      &lt;/jsp-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p>I configured this web.xml to work with commons.fileupload and not with the HTTP Servlet native Upload functionality.</p>
  <p>Please note that I had to seperate ´/*´ with a space (´/ *´) so that the rest of my code wouldn't get formatted as a comment. (If there is a smarter way to do this please don't hesitate to tell me)</p>
  <p>My web application relies on the following technologies/libraries:</p>
  <p>JSF 2.2.9</p>
  <p>HTTP Servlet 3.0.1</p>
  <p>Spring MVC</p>
  <p>Spring Webflow</p>
  <p>Primefaces 6.0 with <code>&lt;f:view renderKitId=&quot;PRIMEFACES_MOBILE&quot; /&gt;</code></p>
  <p>Omnifaces 1.5</p>
  <p>Bootsfaces 0.8.1</p>
  <p>Netbeans as IDE</p>
  <p>For testing and debugging purposes I deploy the app to Jetty 8.1.5 via Netbeans.</p>
  <p>However I tried deploying the app to a Tomcat server as well with the same result.</p>
  <p>Please forgive the long post, I just wanted to include everything that seemed remotely useful. If you need anything else please let me know.</p>
  <p>Thank you very much in advance.</p>
  <h1>EDIT:</h1>
  <p>It appears that my problem does not have anything to do directly with <code>p:fileupload</code> but rather with my <code>p:commandButton</code>s not invoking any action event at all, when I disable ajax. To test this, I added the <code>ajax=&quot;false&quot;</code> attribute to one of my comandButtons on another page. As soon as I added it, my commandButton stopped working and it just refreshed the site but never handled the event specified in the <code>action</code> attribute. Does anyone have an idea why my commandbuttons stop working with <code>ajax=&quot;false&quot;</code>?</p>
  <h1>Edit2</h1>
  <p>I posted a <a href="https://stackoverflow.com/q/39391056/2703623">new question</a> since I discovered that the problem is related to something slightly different</p>