[ https://issues.apache.org/jira/browse/FILEUPLOAD-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13246450#comment-13246450 ]
Darren Hartford commented on FILEUPLOAD-183: -------------------------------------------- Just recently ran into this exact issue with 1.2.2 as well. Commons-io should not be optional. The 'common usecases' always need commons-io. > commons-io dependency does not get loaded by maven if only dependency to > commons-fileupload is specified > -------------------------------------------------------------------------------------------------------- > > Key: FILEUPLOAD-183 > URL: https://issues.apache.org/jira/browse/FILEUPLOAD-183 > Project: Commons FileUpload > Issue Type: Bug > Affects Versions: 1.2.1 > Environment: Maven 2.2.1 > Reporter: Roman Arkadijovych Muntyanu > > If commons-fileupload is added as dependency (without commons-io explicitly > defined) like the following > {code:xml} > <dependency> > <groupId>commons-fileupload</groupId> > <artifactId>commons-fileupload</artifactId> > <version>1.2.1</version> > <scope>compile</scope> > </dependency> > {code} > and fileupload is referenced in the code like > {code:java} > // Create a factory for disk-based file items > FileItemFactory factory = new DiskFileItemFactory(); > // Create a new file upload handler > ServletFileUpload upload = new ServletFileUpload(factory); > // Parse the request > List /* FileItem */ items = upload.parseRequest(request); > {code} > then NoClassDefFoundError occurs > {code:none} > java.lang.NoClassDefFoundError: > org/apache/commons/io/output/DeferredFileOutputStream > at > org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:196) > at > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:358) > at > org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126) > {code} > The reason is that commons-fileupload artifact has *optional* dependency to > commons-io in its pom-file > {code:xml} > <dependency> > <groupId>commons-io</groupId> > <artifactId>commons-io</artifactId> > <version>1.3.2</version> > <optional>true</optional> > </dependency> > {code} > Which results in commons-io not being downloaded and added to the project by > maven. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira