| Author |
No class def found error in apache commons fileupload
|
khushi paul
Greenhorn
Joined: Feb 08, 2005
Posts: 26
|
|
hi all, i am using apache commons file upload for uploading file from servlet. i hv put the jar file in tomcat/common/lib n set the classpath accordingly. i get my code complied but it gives following exception at run time: message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution threw an exception at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)................................................................................ root cause java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUpload at upload.doPost(upload.java:36) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.................................................................................... code which i used is : boolean isMultipart = FileUpload.isMultipartContent(request); out.println(isMultipart); try { List l = fu.parseRequest(request); Iterator i = l.iterator(); while (i.hasNext()) { FileItem fi = (FileItem)i.next(); String filename = fi.getName(); if(!fi.isFormField()) { System.out.println("\nNAME: "+fi.getName()); System.out.println("SIZE: "+fi.getSize()); } catch (Exception e) {out.println(e);} pls help me.... thanks in advance
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Check the jar file again, maybe it got corrupted. BTW: Although putting libs in common/lib will work, it's not the best place for them. common/lib is a placeholder for libraries that are used by Tomcat itself. If you want to share one library among all your apps, you can do this by putting it in /shared/lib. I, personally, prefer to keep them all under WEB-INF within each app, even if this means having multiple copies of the same lib.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
khushi paul
Greenhorn
Joined: Feb 08, 2005
Posts: 26
|
|
thanks Ben, there was some minor classpath error which i sorted out. thanks for ur help Now i can upload the file and write it in some directory but can you pls guide me wat should be done to write it into a database? regards Khushi [ March 02, 2005: Message edited by: khushi paul ]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
It would depend on how you want to write it (text, line by line or as a blob) and what database you are using. You'd probably get better answers in the JDBC forum at this point. You have the file stream. That's the main part (for this forum)..
|
 |
 |
|
|
subject: No class def found error in apache commons fileupload
|
|
|