FileUpload problem

UI Components for JSF
Post Reply
burferd
Posts: 234
Joined: 01 May 2010, 16:15

14 Jun 2010, 21:35

Using PrimeFaces 2.0.2, JSF2, facelets, Gladdfish3.1, NetBeans 6.9

I'm getting a server error trying to deploy my project after adding a p:fileUpload component.

Here is the exception report that gets printed on the page:

Code: Select all

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: PWC1243: Filter execution threw an exception
root cause 

com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class org.primefaces.webapp.filter.FileUploadFilter
root cause 

com.google.common.collect.ComputationException: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
root cause 

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
note The full stack traces of the exception and its root causes are available in the GlassFish 3 logs.

I suspect that it relates to not properly setting up the FileUpload Filter in the web.xml file, but I'm not sure what is wrong.
Here is my web.xml file.

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>
    <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>/faces/*</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>
    <servlet>
        <servlet-name>Comet Servlet</servlet-name>
        <servlet-class>org.primefaces.comet.PrimeFacesCometServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Comet Servlet</servlet-name>
        <url-pattern>/primefaces_comet/*</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </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>faces/LoginPage.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
Here is the component that I am using - basically a duplicate of the example in the documentation:

Code: Select all

                                    <p:fileUpload id="imageUpload" styleClass="imageUpload"
                                                  fileUploadListener="#{uploadSessionBean.action}"
                                                  allowTypes="*.jpg;*.png;*.gif"
                                                  description="Images"
                                                  update="tabSetComp:imageImg" />
The fileUploadListener is just an empty method, right now:
public void action(FileUploadEvent event){ }

If I remove the component from the page and remove the FIleUpload Filter code from the web.xml file, the application deploys without an error.

Any ideas on what I'm doing wrong?

Thanks.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

User avatar
kwintesencja
Posts: 316
Joined: 08 Feb 2010, 20:33
Location: Brazil

25 Jun 2010, 04:09

Hi there, i was facing the same issue and the following jars did the trick

jakarta fileUpload http://linorg.usp.br/apache/commons/fil ... .1-bin.zip

and commons io: http://ftp.unicamp.br/pub/apache/common ... .4-bin.zip


i hope it helps.
Att,

--

Rafael Mauricio Pestano


Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano

burferd
Posts: 234
Joined: 01 May 2010, 16:15

25 Jun 2010, 05:44

Thanks for the feedback.

I figured my problem was a configuration issue.
I'll try the fix you suggest and post the results tomorrow.

Thanks again.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests