3

I am trying to setup Maven, JSF and Primefaces project. But when i run the project i get the following error

com.sun.faces.config.ConfigurationException: 
Source Document: jar:file:/D:/Personal%20Work/eclipse%2032%20Bit/workspace/Java%20EE
/Spring/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
/ch18_SpringWebFlowAndJSF/WEB-INF/lib/primefaces-3.5.jar!/META-INF/faces-config.xml
Cause: Class 'org.primefaces.component.fileupload.FileUploadRenderer' is missing
 a runtime dependency: java.lang.NoClassDefFoundError: org/apache/commons/fileupload
/FileItem

Here is my POM snippet

<properties>
    <java-version>1.6</java-version>
    <org.springframework-version>3.2.3.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.7.5</org.slf4j-version>
    <jsf-version>2.2.0</jsf-version>
</properties>

    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-faces</artifactId>
        <version>2.3.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>${jsf-version}</version>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>${jsf-version}</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.5</version>
    </dependency>
</dependencies>

<repositories>
    <repository>  
        <id>prime-repo</id>  
        <name>PrimeFaces Maven Repository</name>  
        <url>http://repository.primefaces.org</url>  
        <layout>default</layout>  
    </repository>     
</repositories> 

Why i am getting this error?

Thanks

Basit
  • 8,426
  • 46
  • 116
  • 196

1 Answers1

6

java doc says

NoClassDefFoundError Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

org.apache.commons.fileupload.FileItem is a class in FileUpload component of Apache Commons which is missing in your class path. Add following maven dependency for FileUpload component in your pom.xml.

 <dependency>   
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>     
    <version>x.x</version>
 </dependency>

you can also check BalusC's this answer,

Community
  • 1
  • 1
Vipul
  • 816
  • 4
  • 11
  • 26
  • Hi i added a dependency `commons-fileuploadcommons-fileupload1.3` after that i am getting strange error `Caused by: java.lang.NoSuchMethodError: java.util.Collections.emptyIterator()Ljava/util/Iterator;`. Any idea what is that error ? – Basit Jun 13 '13 at 14:55
  • Commons collection is missing add commons collection jar – Vipul Jun 13 '13 at 15:13
  • I had included this jar `commons-collection` but still i was getting the error. Then i remove the dependency `commons-io commons-io20030203.000550` and now things are ok :). Sure i will definitely accept your answer :) ;) – Basit Jun 13 '13 at 15:22
  • Why are you copying the words from an older answer of mine instead of writing in your own words and referencing the found duplicate question/answer as a link and if necessary in a blockquote? The downvote is not for the answer, but for the [plagiarism](http://meta.stackexchange.com/questions/160077/ive-been-accused-of-plagiarism-what-do-i-do). Once you fix that, I'll remove the downvote. – BalusC Jun 13 '13 at 17:02
  • thanks @BalusC I don't know about plagiarism. I have edited my answer can you remove your down vote. – Vipul Jun 14 '13 at 05:02