• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

FileCleaner not found error while using Commons-FileUpload1.1

I am doing the following:-

asking the user to upload a file by using the following servlet trashservlet...
package mypackage6;

public class trashservlet extends HttpServlet {
 
  public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
       
        out.println("<html>");
        out.println("<head>");
         out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\"></meta>");
          out.println("<title>trash</title>");
          out.println("</head>");
          out.println("<body>");
         
          out.println("<form method=\"post\" action=\"loadservlet\" enctype=\"multipart/form-data\">");
        out.println("File");
        out.println("<input type=\"file\" action=\"loadservlet\" name=\"upfile\"/>");
        out.println("<input type=\"submit\"/>");
        out.println("</form>");
         
        out.println("</body>");
        out.println("</html>");
       
        out.close();
    }
}

Now, I am directing the user to another servlet when he selects a file to upload.
To read this uploaded file, i have another servlet called loadservlet. In this servlet, I am getting the error saying

oracle.classloader.util.AnnotatedNoClassDefFoundError:

        Missing class: org.apache.commons.io.FileCleaner

      Dependent class: org.apache.commons.fileupload.disk.DiskFileItem
               Loader: current-workspace-app.web.Application1-eMos-webapp:0.0.0
          Code-Source: /C:/Intern Apps/Java/Java API/commons-fileupload-1.1/commons-fileupload-1.1/commons-fileupload-1.1.jar
        Configuration: <classpath> in C:\Intern Apps\eMOS_052406_0900\Application1\eMos\public_html
The missing class is not available from any code-source or loader in the system.

I am able to track that the error is occuring when the call to the parseRequest is made in the following code.

    public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException {

        RequestContext reqContext = new ServletRequestContext(req);// what for?
       
        String newFileName = "InputFile_"+ System.currentTimeMillis()/1000+".xls";      
     
        if(FileUploadBase.isMultipartContent(reqContext)){    // AM PASSING IT A REQUESTCONTEXT OBJECT
//BECAUSE THE METHOD WHICH HAS REQUEST AS AN ARGUMENT IS NOW DEPRECATED.        



            FileItemFactory factory;
            factory = new DiskFileItemFactory();

            ServletFileUpload upload = new ServletFileUpload(factory);
       
        try{
                List items;
                   // Process the uploaded items
                try {
               
               items = upload.parseRequest(req); /// GETTING AN ERROR HERE
                Iterator iter = items.iterator();                
                FileItem item = (FileItem) iter.next();
                       
   if (item.isFormField()) {

                             }
    else {
                  item.write(new File("C://Fileuploaded_"+System.currentTimeMillis()/1000));
          }
                     
                           
                if(setFileParam(item)==true){
                  System.out.println("file parameters are set");
                    // XferFile(item);
                }else{
                   System.out.println("no form item");                  
                }
               
           }  catch (FileUploadException e){
                    // TODO
                }
        } catch(Exception e){
                System.out.println("error"+e.getMessage());
                e.printStackTrace();
           }
   
   
    }
    }

Can anyone suggest me what is the solution that i need to do. I am using JDeveloper IDE and have imported all the jars of common-fileupload 1.1 in the Jdeveloper libraries so, there is not a problem with the library stuff. I am using the embedded OC4J server in the JDeveloper so it uses libraries from the JDeveloper project libraries. I have seen some solutions which are shown for Tomcat for including the Libraries or something, but that does not work here. Please show me the direction. I am working on this from the last 1 and a half day but i cant find the answer. Please help.
0
SarthakDudhara
Asked:
SarthakDudhara
3 Solutions
 
hoomanvCommented:
I searched google for: site:forums.oracle.com AnnotatedNoClassDefFoundError
and I found that this problem arises because OC4J cant see some dependent  jar files
one told that you shoud place the jars into <OC4J_HOME>/j2ee/home/applib
you yourself may find your answer in these google search results sooner, since this is an Oracle related Q so more likely the answer should be found there
http://www.google.com/search?hl=en&lr=&q=site%3Aforums.oracle.com+AnnotatedNoClassDefFoundError&btnG=Search
0
 
objectsCommented:
> and have imported all the jars of common-fileupload 1.1 in the Jdeveloper libraries so

does that include commons io?
0
 
rrzCommented:
Why not just go here  
http://jakarta.apache.org/site/downloads/downloads_commons-io.cgi 
and get the  jar and put in your classpath.
0
 
rrzCommented:
Sorry, objects I didn't see your post.
0
 
SarthakDudharaAuthor Commented:
thanks, I will have to look at it on monday as i do not have my code and environment set up here.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now