javax.faces.FacesException

UI Components for JSF
Post Reply
zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

01 Sep 2013, 15:15

When i click the link:

Code: Select all

<p:commandLink value="home page" action="home.jsf" target="workspace"/>
I get an Exception:

Code: Select all

WARNING:   javax.servlet.ServletException: The request content-type is not a multipart/form-data
javax.faces.FacesException: javax.servlet.ServletException: The request content-type is not a multipart/form-data
	at org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:44)
	at org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:37)
	at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:836)
	at javax.faces.component.UIInput.decode(UIInput.java:771)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1228)
	at javax.faces.component.UIInput.processDecodes(UIInput.java:676)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at org.primefaces.component.dialog.Dialog.processDecodes(Dialog.java:390)
	at javax.faces.component.UIForm.processDecodes(UIForm.java:225)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at org.primefaces.component.layout.Layout.processDecodes(Layout.java:239)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1223)
	at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:929)
	at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:722)
Caused by: javax.servlet.ServletException: The request content-type is not a multipart/form-data
	at org.apache.catalina.fileupload.Multipart.getPart(Multipart.java:187)
	at org.apache.catalina.connector.Request.getPart(Request.java:4535)
	at org.apache.catalina.connector.RequestFacade.getPart(RequestFacade.java:1095)
	at org.primefaces.component.fileupload.NativeFileUploadDecoder.decodeAdvanced(NativeFileUploadDecoder.java:60)
	at org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:37)
	... 51 more

primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

01 Sep 2013, 15:48

Stacktrace clearly shows "The request content-type is not a multipart/form-data" for fileupload component.It means you should use enctype="multipart/form-data" for fileupload like components.You should post full page code.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

01 Sep 2013, 17:19

also, this was copied from your signature.

Code: Select all

primefaces-4.0-SNAPSHOT.jar,JSF Mojarra 2.2.0
PrimeFaces Mobile 0.9.4, 
glassfish-4.0, 
netbeans 7.3.1
Browser: Firefox 23
are you really using Mojarra 2.2.0? it has been recommended and discussed that it is good to upgrade to (at least) Mojarra 2.2.1 or latest version of Mojarra 2.2.x, since you're using Glassfish 4.0.

what is the date of primefaces 4.0 snapshot that you are using? did you download latest from repository, or you download-and-build via maven? what was the date that you built primefaces 4.0 snapshot?

did you look at latest PrimeFaces user guide and follow all instructions for using p:fileUpload? and your code is similar to what is demonstrated in user guide and showcase?
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

01 Sep 2013, 18:45

I am using Mojarra 2.2.2. I download from repository at 28/8/2013.I follow all instructions in PrimeFaces user guide 3.5 for using p:fileUpload .

MainFrame.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="shortcut icon" href="resources/images/favicon.ico" />
        <h:outputStylesheet name="default.css" library="css"/>
        <h:outputStylesheet name="Skinning.css" library="css"/>
        <title>
            <ui:insert name="title">ETM</ui:insert>
        </title>
    </h:head>
    <h:body>
        <p:layout fullPage="true">
            <p:layoutUnit position="north">
                <ui:include src="./Template/header.xhtml"/>
            </p:layoutUnit>
            <p:layoutUnit position="west" size="150" collapsible="true">
                <ui:include src="./security/MenuTree.xhtml"/>
            </p:layoutUnit>
            <p:layoutUnit position="center">                
                <iframe id="workspace" name="workspace" src="home.jsf" style="width:100%;height: 100%; border: none;"/>
            </p:layoutUnit>
        </p:layout>
    </h:body>
</html>
header.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body  style="margin: 0px;padding: 0">
        <h:form>
            <div class="ui-widget ui-widget-header" style="height:52px;border: 0px;">
                <h:graphicImage library="images" name="logo.png" style="height:50px;" ondblclick="logoDlg.show()"/>
           </div>
            <div style="position: absolute;bottom: 0px;right: 3px">
                <h:panelGrid columns="2">
                    <p:commandLink value="home page" action="home.jsf" target="workspace"/><p:spacer width="10" height="10"/>
                    <p:commandLink value="logout" action="#{securitySession.logout}"/><p:spacer width="10" height="10"/>                    
                </h:panelGrid>
            </div>
<p:dialog id="logoDlg" header="LOGO" widgetVar="logoDlg" appendTo="@(body)">
                <p:fileUpload fileUploadListener="#{sysManager.handleFileUpload}" mode="advanced" dragDropSupport="false" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
            </p:dialog>
        </h:form>
    </h:body>
</html>
home.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet name="default.css" library="css"/>
        <h:outputStylesheet name="Skinning.css" library="css"/>
        <title></title>
    </h:head>
    <h:body>
        <p:layout fullPage="true">
            <p:layoutUnit position="east" size="300">
                <p:layout>
                    <p:layoutUnit position="north" size="300" header="notes">

                    </p:layoutUnit>

                    <p:layoutUnit position="center" header="schedule">

                    </p:layoutUnit>
                </p:layout>
            </p:layoutUnit>

            <p:layoutUnit position="center">
                <p:layout>
                    <p:layoutUnit position="north" size="200" header="alarmInfo">
                        <ui:include src="./cbm/RealtimeAlarm.xhtml"/>
                    </p:layoutUnit>
                    <p:layoutUnit position="south" size="200" header="plan">

                    </p:layoutUnit>
                    <p:layoutUnit position="center" header="defect">

                    </p:layoutUnit>
                </p:layout>
            </p:layoutUnit>
        </p:layout>
    </h:body>
</html>
web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>#{themeManager.theme.name}</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.allowTextChildren</param-name>
        <param-value>true</param-value>
    </context-param>

    <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>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    <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>51200</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>  
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>login.jsf</welcome-file>
    </welcome-file-list>
</web-app>

Last edited by zsuiqiang on 02 Sep 2013, 16:51, edited 1 time in total.
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

01 Sep 2013, 21:17

zsuiqiang wrote:I am using Mojarra 2.2.2. I download from repository at 28/8/2013.
please click user name in upper right corner of this page, edit profile, edit signature, and add mojarra 2.2.2 and Aug-28-2013 date to primefaces 4.0 snapshot...in your signature, so others will not have to ask 'you' this question 'every time' you ask questions here in this forum.
zsuiqiang wrote:I follow all instructions in PrimeFaces user guide 3.5 for using p:fileUpload .
Very interesting. PrimeFaces user guide 3.5 instructed you to use PrimeFaces 4.0 snapshot + Glassfish 4.0? If you are following PrimeFaces 3.5 user guide, then downgrade to PrimeFaces 3.5 and to latest Mojarra 2.1.x (instead of Mojarra 2.2.x).

I looked at your xhtml, and I did not see any p:fileUpload in any of the xhtml that you shared. I only saw web.xml that referenced primefaces upload filter.

also, interesting, I think it has been communicated in this forum that resource servlet has been deprecated or no longer exist in primefaces.

Code: Select all

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
also, interesting, iframe.

Code: Select all

<iframe id="workspace" name="workspace" src="home.jsf" style="width:100%;height: 100%; border: none;"/>
where is the p:fileUpload in your xhtml? please reply with the entire xhtml file that contains p:fileUpload, since that is mentioned in the exception that are asking about.
Last edited by smithh032772 on 06 Nov 2013, 20:25, edited 1 time in total.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

02 Sep 2013, 16:00

Sorry,i don't know where to get 4.0 user guide,so i have to following 3.5 user guide.

Now,i remove the config as bellow from web.xml

Code: Select all

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
I use fileupload in head.xhtml
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

02 Sep 2013, 21:28

sudheer wrote:Stacktrace clearly shows "The request content-type is not a multipart/form-data" for fileupload component.It means you should use enctype="multipart/form-data" for fileupload like components.You should post full page code.
+1 Sudheer hit this nail on the head, immediately/earlier.

i just took a 'better' look (from my development server) at your code below.

Code: Select all

    <h:body  style="margin: 0px;padding: 0">
        <h:form>
            <div class="ui-widget ui-widget-header" style="height:52px;border: 0px;">
                <h:graphicImage library="images" name="logo.png" style="height:50px;" ondblclick="logoDlg.show()"/>
           </div>
            <div style="position: absolute;bottom: 0px;right: 3px">
                <h:panelGrid columns="2">
                    <p:commandLink value="home page" action="home.jsf" target="workspace"/><p:spacer width="10" height="10"/>
                    <p:commandLink value="logout" action="#{securitySession.logout}"/><p:spacer width="10" height="10"/>                    
                </h:panelGrid>
            </div>
<p:dialog id="logoDlg" header="LOGO" widgetVar="logoDlg" appendTo="@(body)">
                <p:fileUpload fileUploadListener="#{sysManager.handleFileUpload}" mode="advanced" dragDropSupport="false" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
            </p:dialog>
        </h:form>
You have the following

Code: Select all

<h:form>
while PrimeFaces 3.5 user guide shows the following in an example for (simple) fileUpload (which also is 'required' for 'advanced' fileUpload)

Code: Select all

<h:form enctype="multipart/form-data">
also, you have this below (2 form-submit commandLinks)

Code: Select all

                <h:panelGrid columns="2">
                    <p:commandLink value="home page" action="home.jsf" target="workspace"/><p:spacer width="10" height="10"/>
                    <p:commandLink value="logout" action="#{securitySession.logout}"/><p:spacer width="10" height="10"/>                    
                </h:panelGrid>
and your p:fileUpload

Code: Select all

                <p:fileUpload fileUploadListener="#{sysManager.handleFileUpload}" mode="advanced" dragDropSupport="false" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
in the same (form)

Code: Select all

<h:form>
you need separate h:form for the 2 form-submit commandlinks

Code: Select all

        <h:form>
                <h:panelGrid columns="2">
                    <p:commandLink value="home page" action="home.jsf" target="workspace"/><p:spacer width="10" height="10"/>
                    <p:commandLink value="logout" action="#{securitySession.logout}"/><p:spacer width="10" height="10"/>                    
                </h:panelGrid>
        </h:form>
and another h:form for the fileUpload

Code: Select all

        <h:form enctype="multipart/form-data">
                <p:fileUpload fileUploadListener="#{sysManager.handleFileUpload}" mode="advanced" dragDropSupport="false" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
        </h:form>
understand?

interesting, i just checked showcase examples for fileUpload, and I see

Code: Select all

<h:form>
instead of

Code: Select all

<h:form enctype="multipart/form-data">
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

05 Sep 2013, 08:23

Thanks a lot!
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 43 guests