Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory

I am trying a simple example of file upload in spring MVC using maven and I follwed this tutorial.

But I am getting this error

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory 

I also included the dependencies in pom.xml

<!-- Apache Commons Upload -->  <dependency>     <groupId>commons-io</groupId>     <artifactId>commons-io</artifactId>     <version>1.3.2</version> </dependency> 

also in dispatcher-servlet.xml

<!-- Configure the multipart resolver --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">     <!-- one of the properties available; the maximum file size in bytes -->     <property name="maxUploadSize" value="100000"/> </bean>  

So, can you help me where I am going wrong.

Thanks in advance.

like image 675
Dharmesh Avatar asked Mar 02 '11 11:03

Dharmesh


1 Answers

You need to add commons-fileupload

add this to your POM

<dependency>    <groupId>commons-fileupload</groupId>    <artifactId>commons-fileupload</artifactId>    <version>1.2.1</version> <!-- makesure correct version here --> </dependency> 
like image 78
jmj Avatar answered Sep 27 '22 02:09

jmj