File uploads are working for small files (under the default 2MB limit), but will not work for larger files. I'm using JSF on Tomcat 8.0 and have modified my web.xml appropriately to increase the limit. I've put breakpoints in the constructor of javax.servlet.MultipartConfig so I can see it reads the web.xml configuration. When the action is called though, it defaults back to the default of 2MB (specifically in Request.parseParts(...) the wrapper's config is null, so uses the connector's default).
WEB.xml:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<multipart-config>
<max-file-size>-1</max-file-size>
<max-request-size>-1</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
</servlet>
home.xhtml
<h:form id="contentFormId" enctype="multipart/form-data">
...
<h:inputFile style="display:none;" id="fileUpload" value="#{bean.uploadItem}">
</h:inputFile>
<h:commandButton id="browse" action="#{bean.fileUploadListener}" value="Add Files" onclick="$('#contentFormId-fileUpload').click()">
</h:commandButton>
...
</h:form>
context.xml
<?xml version="1.0" encoding="utf-8"?>
<Context allowCasualMultipartParsing="true"
...
</Context>
Updated After creating a simplified application, it appears that the Rewrite library is causing a different container wrapper to be used in the request.
Without Rewrite:
Request.getWrapper()
returns StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestWeb].StandardWrapper[Faces Servlet]
With Rewrite @URLMapping
annotation:
Request.getWrapper()
returns StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestWeb].StandardWrapper[default]
So it seems that I need to configure this application's default container similar to how Faces is configured, or find a way to get Rewrite to delegate to the Faces Servlet container. Editing the maxPostSize in Tomcat is an option (change the default), but not one I want to take if I can avoid it.