The moose likes JSP and the fly likes commons fileupload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "commons fileupload problem" Watch "commons fileupload problem" New topic

commons fileupload problem

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Hello guys!
Thanks for your attention.

My problem is when I run the programme,it always throw an exception when the code goes to "parseRequest".

Sourcecode is shown below:

// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();

// Set factory constraints
factory.setSizeThreshold(1000 * 1024);

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);

// Set overall request size constraint
upload.setSizeMax(100 * 1024);

// Parse the request
List /* FileItem */ items = upload.parseRequest(request);

Exception is:

javax.servlet.ServletException: Servlet execution threw an exception

root cause

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

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Where did you put the jar files (the ones that came with Commons Fileupload)?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
I put it in the lib directory which is in my own application
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Sorry man,I forgot to put the io jar in the classpath.
problem is solved.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Glad it's working for you.
I agree. Here's the link: http://aspose.com/file-tools
subject: commons fileupload problem
Similar Threads
uploading a log file to data base by using servlet.
Using Apache FileUpload package with JSP
commons-fileupload problem
Error while parsing simple plain text fields in multipart form at Restlet 1.1
Upload servelet issues