[Solved] java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory

I encountered this exception while building spring MVC file upload example. The error stacktrace looks like this:

java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
	at java.lang.Class.getDeclaredMethods(Unknown Source)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:571)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:490)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:474)

exceptions-notes

Solution

You have incorrect version of apache commons-fileupload. To solve this error, you correct version 1.2.1.

<dependency>
	<groupId>commons-fileupload</groupId>
	<artifactId>commons-fileupload</artifactId>
	<version>1.2.1</version>
</dependency>

<dependency>
	<groupId>commons-io</groupId>
	<artifactId>commons-io</artifactId>
	<version>2.5</version>
</dependency>

This will solve your error.

Happy Learning !!

Comments

Subscribe
Notify of
guest
3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode