Uploaded image for project: 'Commons FileUpload'
  1. Commons FileUpload
  2. FILEUPLOAD-183

commons-io dependency does not get loaded by maven if only dependency to commons-fileupload is specified

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      Maven 2.2.1

      Description

      If commons-fileupload is added as dependency (without commons-io explicitly defined) like the following

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

      and fileupload is referenced in the code like

      // 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);
      

      then NoClassDefFoundError occurs

       
      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)
      

      The reason is that commons-fileupload artifact has optional dependency to commons-io in its pom-file

      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
        <optional>true</optional>
      </dependency>
      

      Which results in commons-io not being downloaded and added to the project by maven.

        Attachments

          Activity

            People

            • Assignee:
              simone.tripodi Simone Tripodi
              Reporter:
              coldserenity Roman Arkadijovych Muntyanu
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: