[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 !!

Was this post helpful?

Join 7000+ Fellow Programmers

Subscribe to get new post notifications, industry updates, best practices, and much more. Directly into your inbox, for free.

3 thoughts on “[Solved] java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory”

Leave a Comment

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.