FileSizeLimitExceededException on Primefaces portlet

Ignacio Santos Alonso, modified 11 Years ago. Junior Member Posts: 50 Join Date: 2/12/13 Recent Posts
Hello all,

I'm using the "official" Primefaces portlet (primefaces3-portlet-3.2.4-ga5) as a base for a development where I have to upload large files to the server.
I've been facing an issue when uploading files on both portlets and I don't know what to do about it:


Caused by: org.apache.commons.fileupload.FileUploadBase$FileSizeLimitExceededException: The field _1_WAR_primefaces3portlet_INSTANCE_Kjepi6YToLlM_:j_idt14:c2:j_idt33:c2a:j_idt44 exceeds its maximum permitted size of 104857600 bytes.
at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl$1.raiseError(FileUploadBase.java:763)
... 156 more
08:58:22,043 ERROR [RequestParameterMapMultiPartImpl:378] Stream closed
java.io.IOException: Stream closed


I run into this exception both with the official Primefaces portlet and my own portlet.
On my portlet I tried using this configuration on web.xml:


 <!-- http://www.mastertheboss.com/jboss-web/primefaces/primefaces-file-upload-example -->
  <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>500000000</param-value>
	  </init-param>
  </filter>
  <filter-mapping>
	  <filter-name>PrimeFaces FileUpload Filter</filter-name>
	  <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>


I also tried setting extremely large file size limits on all possible settings of the Control Panel -> Server administration -> File uploads.
In addition to that, we also set the property com.liferay.portal.upload.UploadServletRequestImpl.max.size in portal-ext.properties, as suggested in
https://www.liferay.com/community/forums/-/message_boards/message/6036219

Nothing seems to work, we keep getting the same error as if we hadn't changed the file size limits.

Is this a bug in Liferay?
thumbnail
Juan Gonzalez, modified 11 Years ago. Liferay Legend Posts: 3089 Join Date: 10/28/08 Recent Posts
Hola Ignacio,

what Liferay version are you using?
Ignacio Santos Alonso, modified 11 Years ago. Junior Member Posts: 50 Join Date: 2/12/13 Recent Posts
Hi/Hola Juan,

I'm using a 6.2 CE.

Thanks.
Ignacio Santos Alonso, modified 11 Years ago. Junior Member Posts: 50 Join Date: 2/12/13 Recent Posts
I've also tried using the conventional upload which worked in other versions of the portal, not using the Primefaces upload tag but instead a very basic input type="file" tag.

I get the same error:

Caused by: org.apache.commons.fileupload.FileUploadBase$FileSizeLimitExceededException: The field zipComunidad exceeds its maximum permitted  size of 104857600 bytes.
	at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl$1.raiseError(FileUploadBase.java:763)
	... 158 more
11:50:36,064 ERROR [RequestParameterMapMultiPartImpl] Stream closed


I'm still using Primefaces web.xml configuration and libraries though but the problem might be related to some portal misconfiguration or bug. I'll keep running tests.

Any help will be appreciated.
thumbnail
Neil Griffin, modified 11 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Ignacio,

When using p:fileUpload in a portlet environment, Liferay Faces Bridge performs all of the file upload processing of the multipart request.

The 100MB limit is a default provided by Liferay Faces Bridge in RequestParameterMapMultiPartImpl.java.

You can increase the limit by specifying an init-param in WEB-INF/portlet.xml named javax.faces.UPLOADED_FILE_MAX_SIZE

Note: When version 3.2.5-ga6 is released, the name of the init-param will be com.liferay.faces.bridge.uploadedFileMaxSize


Kind Regards,

Neil
Ignacio Santos Alonso, modified 11 Years ago. Junior Member Posts: 50 Join Date: 2/12/13 Recent Posts
Thanks a lot for the tip Neil,I finally got rid of the error but the file upload component still doesn't work.
It seems to upload the file (it shows a progress bar and the larger the file, the longer it takes to fill the bar) but when it has finished loading the file it does nothing.
The fileUploadListener is never called.

VIEW.XHTML (RELEVANT CODE)

<p:fileupload fileUploadListener="#{migradorBean.handleFileUpload}" mode="advanced" uploadLabel="Cargar" cancelLabel="Cancelar" label="Seleccione archivo ZIP a importar" />
				  <br><br><p:messages id="msgs" showDetail="true" />


BACKING BEAN (RELEVANT CODE) -> The log.info message never shows up, neither does the faces message

public void handleFileUpload(FileUploadEvent event) {
    	log.info("Entrando en fileUploadListener");
    	FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Fichero "+ event.getFile().getFileName() + " cargado","Se procede a importar la comunidad");  
        FacesContext.getCurrentInstance().addMessage(null, msg); 



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" version="2.5">
  	<!-- Instruct Mojarra to utilize JBoss-EL instead of the EL implementation provided by the servlet container. -->
	<context-param>
		<param-name>com.sun.faces.expressionFactory</param-name>
		<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
	</context-param>
  <!-- Workaround for http://issues.liferay.com/browse/FACES-1194 -->
	<context-param>
		<param-name>com.liferay.faces.bridge.primeFileUploadForceResourceURL</param-name>
		<param-value>true</param-value>
	</context-param>
  <!-- http://www.mastertheboss.com/jboss-web/primefaces/primefaces-file-upload-example -->
 <!-- No incluido de momento -->
  <!-- Servlet para arrancar el listener de message bus que permite funcionar al quartz -->  
  <servlet>
    <servlet-name>ServletInitializer</servlet-name>
    <servlet-class>es.juntadeandalucia.ced.migrador_comunidades.arq.ServletInitializer</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <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>*.xhtml</url-pattern>
  </servlet-mapping>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Facelet View XHTML</web-resource-name>
      <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>nobody</role-name>
    </auth-constraint>
  </security-constraint>
  <security-role>
    <role-name>nobody</role-name>
  </security-role>
</web-app>


PORTLET.XML

<!--?xml version="1.0"?-->

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
	<portlet>
		<portlet-name>blablabla</portlet-name>
		<display-name>blablabla</display-name>
		<portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.view</name>
			<value>/views/view.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.help</name>
			<value>/views/help.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.faces.UPLOADED_FILE_MAX_SIZE</name>
			<value>504857600</value>
		</init-param>
		<expiration-cache>0</expiration-cache>
		<supports>
			<mime-type>text/html</mime-type>
			<portlet-mode>view</portlet-mode>
			<portlet-mode>help</portlet-mode>
		</supports>
		<portlet-info>
			<title>blablabla</title>
			<short-title>blablabla</short-title>
			<keywords>blablabla</keywords>
		</portlet-info>
		<security-role-ref>
			<role-name>administrator</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>guest</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>power-user</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>user</role-name>
		</security-role-ref>
	</portlet>
</portlet-app>


I'm working with the libraries supplied by the Primefaces portlet (primefaces3-portlet-3.2.4-ga5) and some other additional jar.
I'm not even sure that the Primefaces portlet installed on our Liferay is working fine, because when it's done loading the attachments for the job application it does nothing, it doesn't update the attached files table.

There's probably a common problem for both the Primefaces Liferay demo portlet and my portlet.

Any ideas?
thumbnail
Neil Griffin, modified 11 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Ignacio,

Does the primefaces3-portlet demo work for small file uploads? Or does it only fail for large (> 100mb) uploads?

Thanks,

Neil
Ignacio Santos Alonso, modified 11 Years ago. Junior Member Posts: 50 Join Date: 2/12/13 Recent Posts
Hi Neil,

I had only tried with large files, but small files ( <100MB ) work ok and if I check the log I see the error I posted above about size.
So I tried applying your solution to the Primefaces demo portlet and deployed again... and it works perfectly!
I'll check my own project and see what's missing.

Thank you very much for pointing me in the right direction.

Cheers.
thumbnail
Neil Griffin, modified 11 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Ignacio,

I'm very glad to know that it is working for you now. Thanks for using Liferay Faces. emoticon

Neil
thumbnail
Daniel S., modified 11 Years ago. New Member Posts: 3 Join Date: 1/30/15 Recent Posts
Hi,

I'm currently trying out this upload feature and I wonder if there is an actual limit for the file size.

I've currently set the limit to 1009715200 (1GB\) and uploads of 1GB files work.

But if I put in for example 3029145600 and try to upload a 2GB file it stops after about 100MB.

Is there something like an internal limit for that value which makes it fall back to the 100MB standard value if it's exceeded?

Thanks & BR

Daniel


Edit:

Ok, the limit is 2147483647, it's an Integer emoticon
thumbnail
Neil Griffin, modified 11 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
See answer at the forum post titled PortletConfigParam only handles Integer, change to Long.