aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "commons fileupload problem" Watch "commons fileupload problem" New topic
Author

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);
factory.setRepository("c:\\temp");

// 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
org.apache.commons.fileupload.DefaultFileItemFactory.createItem(DefaultFileItemFactory.java:102)
org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
com.prismt.licensegenerator.servlet.FileUpload.service(FileUpload.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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


truehh@hotmail.com
Ben Souther
Sheriff

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.
Thanks!
Ben Souther
Sheriff

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