tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gabi maier <wizard_roma...@yahoo.com>
Subject problem using apache's commons-fileupload-1.1 package
Date Mon, 01 May 2006 09:26:29 GMT
                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.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message