Problem

Doing some I/O works in Struts framework, but hits following exception in file upload process.


java.lang.NoClassDefFoundError: 
        org/apache/commons/io/output/DeferredFileOutputStream

Where to download the Apache commons-io?

Solution

By default, Struts is using Apache “commons-io.jar” for its file upload process. To fix it, you have to include this library into your project dependency library folder.

1. Get Directly

Get “commons-io.jar” from official website – http://commons.apache.org/io/

2. Get From Maven

The prefer way is get the “commons-io.jar” from Maven repository

File : pom.xml


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