Using @multipartconfig in a servlet running on GlassFish 3.2.2

Today I run into a problem with a custom JSF component using the @MultipartConfig. Trying to use my FileUpload Bean (http://www.imixs.org/jsf/fileupload.html) results in the following error message:

[#|2013-04-26T15:37:21.769+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=Thread-2;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: PWC4016: Request.getParts is called without multipart configuration.  Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml

It seems that this error did not be thrown on a GlassFish 3.2.1 server.

Finally I was able to fix the problem when adding the following servlet configuration into the web.xml file for my Faces Servlet.

 ...
	<!-- Facelets -->
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>0</load-on-startup>		
		<multipart-config>
	    	  <location>/tmp</location>
	    	  <max-file-size>20848820</max-file-size>
	    	  <max-request-size>418018841</max-request-size>
	    	  <file-size-threshold>1048576</file-size-threshold>
		</multipart-config>
        </servlet>
.....

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.