You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by gabi maier <wi...@yahoo.com> on 2006/05/01 11:26:29 UTC

problem using apache's commons-fileupload-1.1 package

                i have a problem uploading files to a servlet from a browser (html) client. i am using the apache commons-fileupload-1.1 jar... i describe my problem below. i pasted the servlet's java source code, the html i use for uploading and the error i get.    when i try uploading i get the following exception: java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
although i'm not using any DeferredFileOutputStream object anywhere nor am i importing this class at any time... could someone help?
   
   
  ===========The=Java=Class======using=Commons=FileUpload================================
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
  
public class TestUpload  extends HttpServlet{
 public void doPost(HttpServletRequest request, HttpServletResponse response)
 throws IOException, ServletException{
    boolean isMultipart = FileUpload.isMultipartContent(request);
  if(isMultipart){
   // Create a factory for disk-based file items
   FileItemFactory factory = new DiskFileItemFactory();
     // Create a new file upload handler
   ServletFileUpload upload = new ServletFileUpload(factory);
   List /* FileItem */ items=null;
     // Parse the request
   try{
/*line 58*/    items = upload.parseRequest(request);
   }catch(FileUploadException except){
    /*...*/
   }
  }
 }
  =============The=HTML=File================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    www.pspad.com">
  <title>pagina mea</title>
  </head>
        <form enctype="multipart/form-data" action="http://localhost/servlet/TestUpload" method="post">
      <input type="file" name="myFileInput">
      <input type="submit" name="mySubmit">
    </form> 
  </html>
  ======The=Servlet=Output============================
  HTTP Status 500 - 
  --------------------------------------------------------------------------------
  type Exception report
  message 
  description The server encountered an internal error () that prevented it from fulfilling this request.
  exception 
  javax.servlet.ServletException: Invoker service() exception
 org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:477)
 org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  
root cause 
  java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
 org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:179)
 org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
 org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
 org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:116)
 TestUpload.doPost(TestUpload.java:58)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
 org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


		
---------------------------------
Blab-away for as little as 1ยข/min. Make  PC-to-Phone Calls using Yahoo! Messenger with Voice.

Re: problem using apache's commons-fileupload-1.1 package

Posted by robert burrell donkin <ro...@gmail.com>.
tomcat-dev is for discussions about the development of Apache Tomcat.
questions about using Tomcat should be addressed to the user list.

however, this question is actually about commons-fileupload. It should have
been posted to the commons-user list. please read
http://jakarta.apache.org/site/mail2.html.

On 5/1/06, gabi maier <wi...@yahoo.com> wrote:
>
>                 i have a problem uploading files to a servlet from a
> browser (html) client. i am using the apache commons-fileupload-1.1 jar...
> i describe my problem below. i pasted the servlet's java source code, the
> html i use for uploading and the error i get.    when i try uploading i get
> the following exception: java.lang.NoClassDefFoundError:
> org/apache/commons/io/output/DeferredFileOutputStream
> although i'm not using any DeferredFileOutputStream object anywhere nor am
> i importing this class at any time... could someone help?


 in this case, though, a quick glance at the root cause:

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


provides enough information  to diagnose the issue. commons-fileupload is
missing a dependency. please read
http://jakarta.apache.org/commons/fileupload/dependencies.html (and the rest
of the documentation).

please post any followups to the appropriate list (commons-users).

- robert