Attachements with apache commons fileupload

I'm using:
http://commons.apache.org/fileupload/
to write file on server side (Tomcat running on Windows with XP or 2003).
I'm sending data to servlet with doPost() as follows:
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            DiskFileItemFactory factory = new DiskFileItemFactory();
            factory.setSizeThreshold(4096);
            factory.setRepository(new File("test"));
            ServletFileUpload upload = new ServletFileUpload(factory);
            upload.setSizeMax(1000000);
            List fileItems = upload.parseRequest(request);
            Iterator i = fileItems.iterator();
            String comment = ((FileItem) i.next()).getString();
            FileItem fi = (FileItem) i.next();
            String fileName = fi.getName();
            // db
            fi.write(new File("C:/", fileName));
        } catch (Exception ex) {
            out.print(ex.getMessage());
        out.close();
    }but it's response is:
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: Servlet execution threw an exception
     org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
     org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:196)
     org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:358)
     org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
     Upload.doPost(Upload.java:69)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
     java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
     org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:196)
     org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:358)
     org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
     Upload.doPost(Upload.java:69)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
     org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
Apache Tomcat/6.0.16don't know why.. any ideas?

java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStreamThe mentioned class is missing in the runtime classpath.
Add it (in this specific case, the JAR file with the mentioned class) to the classpath and the problem will disappear.
This class is part of Commons IO. Read the dependencies page at FileUpload user guide which JAR's you all need.

Similar Messages

  • Problems with Apache Commons FileUpload

    I'm completely stymied here. I've been trying to get the Apache Commons FileUpload working with a JBoss 4.2 server, and having no luck whatsoever. The servlet is listed out here:
    package com.areteinc.servlets;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileItemFactory;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    public class Filer extends HttpServlet {
         private Logger logger = Logger.getLogger(Filer.class);
         public Filer() {
              logger.setLevel(Level.DEBUG);
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              logger.debug("Serving up a GET page...");
              PrintWriter writer = resp.getWriter();
              StringBuffer response = new StringBuffer();
              response.append("<HTML><HEAD><TITLE>JENA File Uploader</TITLE></HEAD><BODY>");
              response.append("<FORM action=\"Filer\" method=\"POST\" enctype=\"multipart/form-data\">");
              response.append("Upload file: <input type=\"file\" name=\"file1\"/><br>");
              response.append("Upload file: <input type=\"file\" name=\"file2\"/><br>");
              response.append("<input type=submit value=\"Start upload\">");
              response.append("</BODY>");
              writer.println(response);
         protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              // First see if someone is uploading more than one file at a time...
              boolean isMultipart = ServletFileUpload.isMultipartContent(req);
              logger.debug("Received a POST request.  Multipart is flagged as " + isMultipart);
              // Create a factory for disk-based file items
              FileItemFactory factory = new DiskFileItemFactory();
              // Create a new file upload handler
              ServletFileUpload upload = new ServletFileUpload(factory);
              // Parse the request
              try {
                   List<FileItem> items = upload.parseRequest(req);
                   Iterator itr = items.iterator();
                   logger.debug("Size of upload is " + items.size() + " items.");
                   while(itr.hasNext()) {
                        FileItem item = (FileItem) itr.next();
                        logger.debug("Filename is " + item.getName());
              } catch (FileUploadException e) {
                   e.printStackTrace();
    }When run, I hit it with a get operation, and get the form. When I put in 2 forms (in reality, all i want to do is use one, but I'm tinkering), I see nothing in items list...
    Run, with 2 files selected to upload:
    13:50:15,421 DEBUG [Filer] Received a POST request. Multipart is flagged as true
    13:50:15,421 DEBUG [Filer] Size of upload is 0 items.
    I've tried variation after variation after variation, and it jst doesn't work. I'm using commons-fileupload-1.2.1.
    Help! :)

    On the client side, the client's browser must support form-based upload. Most modern browsers do, but there's no guarantee. For your case,
    The servlet can use the GET method parameters to decide what to do with the upload while the POST body of the request contains the file data to parse.
    When the user clicks the "Upload" button, the client browser locates the local file and sends it using HTTP POST, encoded using the MIME-type multipart/form-data. When it reaches your servlet, your servlet must process the POST data in order to extract the encoded file. You can learn all about this format in RFC 1867.
    Unfortunately, there is no method in the Servlet API to do this. Fortunately, there are a number of libraries available that do. Some of these assume that you will be writing the file to disk; others return the data as an InputStream.
    Jason Hunter's MultipartRequest (available from [http://www.servlets.com/])
    Apache Jakarta Commons Upload (package org.apache.commons.upload) "makes it easy to add robust, high-performance, file upload capability to your servlets and web applications"
    *CParseRFC1867 (available from [http://www.servletcentral.com/]).
    *HttpMultiPartParser by Anil Hemrajani, at the isavvix Code Exchange
    *There is a multipart/form parser availailable from Anders Kristensen ([http://www-uk.hpl.hp.com/people/ak/java/] at [http://www-uk.hpl.hp.com/people/ak/java/#utils].
    *JavaMail also has MIME-parsing routines (see the Purple Servlet References).
    *Jun Inamori has written a class called org.apache.tomcat.request.ParseMime which is available in the Tomcat CVS tree.
    *JSPSmart has a free set of JSP for doing file upload and download.
    *UploadBean by JavaZoom claims to handle most of the hassle of uploading for you, including writing to disk or memory.
    There's an Upload Tag in dotJ
    Once you process the form-data stream into the uploaded file, you can then either write it to disk, write it to a database, or process it as an InputStream, depending on your needs. See How can I access or create a file or folder in the current directory from inside a servlet? and other questions in the Servlets:Files Topic for information on writing files from a Servlet.
    Please note: that you can't access a file on the client system directly from a servlet; that would be a huge security hole. You have to ask the user for permission, and currently form-based upload is the only way to do that.
    I still have doubt if all the moentioned resources are alive or not

  • Apache commons FileUpload: Pass stream as attribute

    I'm trying to implement a Filter that will change all the HTTP parameters to attributs, so that I can handle them in a consistent way throughout my servlets. The apache commons fileupload part is giving me problems. I'm changing the parameters to attributes like this
    if(URLENCODED.equalsIgnoreCase(contentType) || contentType == null) // Used with normal form data
      Enumeration<String> params = request.getParameterNames();
      while(params.hasMoreElements())
        String name = params.nextElement();
        String value = request.getParameter(name);
        request.setAttribute(name, value);
    else if(contentType.toLowerCase().startsWith(MULTIPART))     // Used when file is uploaded with POST               
      // Create file upload handler
      ServletFileUpload upload = new ServletFileUpload();
      FileItemIterator iter;
      iter = upload.getItemIterator((HttpServletRequest) request);
      while(iter.hasNext())
        FileItemStream item = (FileItemStream)iter.next();
        InputStream itemStream = item.openStream();
        if(item.isFormField())          // form item
          BufferedReader rd = new BufferedReader(new InputStreamReader(itemStream));
          String line;
          while((line = rd.readLine()) != null)
            streamParamsToAttributes(line)
      else          // file
        request.setAttribute("filestream", itemStream);
    }In my servlet I use the file stream with following code
    InputStream itemStream = (InputStream)(request.getAttribute("filestream"));
    useStream(itemStream)Here the useStream() method will throw a FileItemStream.ItemSkippedException since I'm trying to read data from the stream after the iter.next() was called.
    So my question is, how to handle this kind of situation? The file can be quite big, so reading it to memory is not wise. And as I read, copying the stream is not a straight-forward task.
    I noticed that O'Reilly has also a library for handling file uploads, is it any better in this case?
    Thanks.

    I looked at the O'Reilly lib and it seems to always save the file to disk. So no streaming possibility.
    One solution I can think of would be to 'manually' read the data from the request. I can get the data with request.getReader() call. The file data can be found by the boundary. Now I'm wondering whether this will solve anything. Can anyone see some caveats in this approach?

  • File size with Jakarta Commons FileUpload

    Hello fella experts,
    I am using the org.apache.commons.FileUpload package to upload a file via a servlet.
    I'm implementing the DiskFileUpload() method in the servlet.
    My problem is that I want to apply a file-size validation and specify that files with size greater than 1MB should not be uploaded.
    How to accomplish this ?
    Any suggessions ?
    Thanx in advance.

    Hi, I'm trying this code, and it works pretty fine, but when I try to transfer a .zip file, it give me a .zip file that I can't extract.
    Please.. Am I doing something wrong, do I miss something??
    I set already the File Type to binary...
    any comments..
    public static void copyFiles(String server, String user, String pwd, String origen, String destino)
    try {
    FTPClient ftp = new FTPClient();
    ftp.connect(server);
    ftp.login(user,pwd);
    ftp.setFileType(ftp.BINARY_FILE_TYPE);     
    //ftp.enterLocalPassiveMode();
    ftp.changeWorkingDirectory(origen);
    int reply = ftp.getReplyCode();
    if(!FTPReply.isPositiveCompletion(reply)) {
    ftp.disconnect();
    FTPFile[] files = ftp.listFiles();
    FTPFile ftpfile = null;
    OutputStream output = null;
    for (int i = 0; i < files.length; i++) {
    ftpfile = files;
    if (ftpfile.isFile()){
    output = new FileOutputStream(new File(destino+ftpfile.getName()));
    if (ftp.retrieveFile(ftpfile.getName(),output)){
    output.close();
    ftp.logout();
    ftp.disconnect();
    } catch (Exception e) {
    e.printStackTrace();
    System.out.println("Error : " + e.toString());

  • I am trying to use apache commons fileupload and get this error

    I am using tomcat 5.5 as application server and JDK 1.6,
    does anybody have idea how to resolve this error ?
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.security.AccessControlException: access denied (java.util.PropertyPermission java.io.tmpdir read)
         java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         java.security.AccessController.checkPermission(AccessController.java:546)
         java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
         java.lang.System.getProperty(System.java:652)
         org.apache.commons.fileupload.disk.DiskFileItem.getTempFile(DiskFileItem.java:611)
         org.apache.commons.fileupload.disk.DiskFileItem.getOutputStream(DiskFileItem.java:556)
         org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:362)
         org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
         project.UploadFiles.processRequest(UploadFiles.java:48)
         project.UploadFiles.doPost(UploadFiles.java:107)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)

    Make sure that the servlet has permissions to write to that directory. I've hit that snag before, and on linux I set the permissions to nobody nobody 775.
    Good luck,
    Krista

  • Org/apache/commons/fileupload/FileUploadException

    hia all,
    i am trying to save an image using <html:file> tag in jsp pages
    usig struts
    Before doing any save action,i am getting this error
    any one know
    thanx
    8:41:52,714 ERROR [Engine] StandardWrapperValve[FrontController]: Servlet.service() for servlet FrontController threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
         at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:145)
         at org.apache.struts.util.RequestUtils.getMultipartHandler(RequestUtils.java:564)
         at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:430)
         at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:150)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:536)

    Commons-fileupload.jar is already in the web-inf/lib.
    Is there another solution?Add the jar to the server's shared/lib or common/lib. Did you really need to ask this on an old thread?

  • Apache commons fileUpload parseRequest finds no form fields-portalComponent

    Hello All,
    What am I trying?
    Developing a portal component (no JSP, no HTMLB).
    Have used Apache commons fileUpload libraries.
    What is the problem?
    parseRequest method works fine when I right click and preview from PCD.
    parseRequest method returns 0 html form elements when the portal component is tested under the TLN (via role -> workset -> iview)
    What else did I try?
    1.
    I looked in to Apache documentation - there are two different APIs for two different scenarios, Servlets and Portlets.
    My understanding is that I can not use portlets scenario in SAP Portal.
    Servlets scenario was what worked while doing a preview from PCD.
    2. I have looked into other solutions like using web dynpro and HTMLB to do file upload - not really a fan of either for various reasons.
    Can any one help?
    I am trying to understand why the HTTPServletRequest when parsed returns 0 form elements in the SAP Portal scenario.
    Thanks!

    Hello Ankur,
    You said:
    The reason for this is, unlike the request parameters, the multipart formdata is 'read-once-only' (because once
    the data is read off the ServletInputStream, it is gone! It cannot be read again). When you call a full portal request it goes through lot of gets before reaching your component.
    The above concept is not fully clear to me. I got a hint to something like this happening from this link that explains the need for portlets API scenario compared to a servlets scenario - Link: http://commons.apache.org/fileupload/using.html
    (Search for Servlets and Portlets within that link)
    I initially thought something like what you had replied would have happened. However, when I do a getContentLength on HTTPServletRequest in the SAP Portal mode (role -> workset -> iview), the size still includes that of the uploaded document. So like you said "it is gone! It cannot be read again" may not be accurate.
    My question still remains open.
    Edited by: Mohammed on Aug 24, 2009 6:29 PM

  • JSP error java.lang.NoClassDefFoundError: org/apache/commons/fileupload/Fil

    I'm rather new to jsp. I'm using myeclipse and I'm deploying my site on tomcat. I've been slowly working away on the errors in my log files. Most of the problems that I've run into have been missing jar files. The log error that I'm stuck on follows:
    10:14:40,359 ERROR [Faces Servlet]:253 - Servlet.service() for servlet Faces Servlet threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUpload
         at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:115)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at com.wolverinecrane.view.util.SecurityFilter.doFilter(SecurityFilter.java:77)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    In my buildpath I have commons-fileupload-1.0.jar which includes org.apache.commons.fileupload which has the class FileUpload.class in it.
    Any help on what may be going wrong here would be appreciated.
    Dan

    Solved:
    http://javalive.com/modules/newbb/viewtopic.php?topic_id=355&post_id=1013&order=0&viewmode=flat&pid=0&forum=4#forumpost1013

  • Error when attempting to upload:org/apache/commons/fileupload/disk/DiskFile

    Hi there,
    I am attempting to use struts to upload an image to a folder within my application.
    The following error is given:
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/disk/DiskFileItem
         org.apache.struts.upload.CommonsMultipartRequestHandler.addTextParameter(CommonsMultipartRequestHandler.java:388)
         org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:204)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:405)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:818)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:194)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)Does anyone know what could be causing this?
    I have copied all the commons jars into both tomcat and my WEB-INF/lib directory. I am running the application on tomcat through Eclipse. Would this cause any problems?
    Many thanks...

    Diablo,
    I did already have the jar, but it was an older version. I downloaded the newer version and it worked fine.
    Thanks for making me look again at something I had discounted!

  • Java.lang.NoClassDefFoundError: org/apache/commons/fileupload/DiskFileUploa

    i have a servlet for the upload of the files...I compile and it's ok, but in esecution i've this error:
    java.lang.NoClassDefFoundError: org/apache/commons/fileupload/DiskFileUpload
    Why? Any idea?
    The classpath it's ok...
    Thanx !

    Ah...I use package commons-fileupload-1.0.jar
    I hope in your answer...Thanx!

  • How to do a file upload & download using Apache Commons FileUpload?

    Hi, I have read through the user guide but I don't understand what are the steps as to implementing the functions...
    http://commons.apache.org/fileupload/using.html
    How do I Create a servlet to read the contents(filename) of te dir where the files are, then create a collection (ArrayList for instance) with the files path and send this collection back to a jsp page.In jsp page, iterate through the collection and build the links (with scriptlets or c tags)
    Can help? Thanks for the guidance!

    This is my single_upload_page.jsp
    <%@ page import="java.io.*" %>
    <%
         //to get the content type information from JSP Request Header
         String contentType = request.getContentType();
         //here we are checking the content type is not equal to Null and
    //as well as the passed data from mulitpart/form-data is greater than or
    //equal to 0
         if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
              DataInputStream in = new DataInputStream(request.getInputStream());
              //we are taking the length of Content type data
              int formDataLength = request.getContentLength();
              byte dataBytes[] = new byte[formDataLength];
              int byteRead = 0;
              int totalBytesRead = 0;
              //this loop converting the uploaded file into byte code
              while (totalBytesRead < formDataLength) {
                   byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
                   totalBytesRead += byteRead;
              String file = new String(dataBytes);
              //for saving the file name
              String saveFile = file.substring(file.indexOf("filename=\"") + 10);
              saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
              saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+ 1,saveFile.indexOf("\""));
              int lastIndex = contentType.lastIndexOf("=");
              String boundary = contentType.substring(lastIndex + 1,contentType.length());
              int pos;
              //extracting the index of file
              pos = file.indexOf("filename=\"");
              pos = file.indexOf("\n", pos) + 1;
              pos = file.indexOf("\n", pos) + 1;
              pos = file.indexOf("\n", pos) + 1;
              int boundaryLocation = file.indexOf(boundary, pos) - 4;
              int startPos = ((file.substring(0, pos)).getBytes()).length;
              int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
              // creating a new file with the same name and writing the content in new file
              String folder = "C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/ROOT/test/x/";     
              FileOutputStream fileOut = new FileOutputStream(folder + saveFile);     
                             //out.print("Saved here: " + saveFile);     
                             //fileOut.write(dataBytes);     
              fileOut.write(dataBytes, startPos, (endPos - startPos));
              fileOut.flush();
              fileOut.close();
              %><Br><table border="2"><tr><td><b>You have successfully upload the file by the name of:</b>
              <% out.println(saveFile); %></td></tr></table> <%
    %>

  • Problems with Apache Commons Validator

    Hello there,
    I got a quiet big problem using the a.m. validation framework. When defining a validation rule for a property like this:
    <formset>
    <form name="testForm">
    <field property="firstName" depends="isEmail">
    <arg0 key="testForm.firstname"/>
    </field>
    </form>
    </formset>
    and instanciating my validator as follows:
    Validator validator = new Validator(resources, "testForm");
    validator.setParameter(Validator.BEAN_PARAM, name);
    everything works fine! I get a correct ValidatorResult object with a correct validation value.
    But as soons as I define a second Validation on the same property like this:
    <formset>
    <form name="testForm">
    <field property="firstName" depends="isEmail,isBlankOrNull">
    <arg0 key="testForm.firstname"/>
    </field>
    </form>
    </formset>
    Nothing works anymore. When iterating over the ValidatorResults object I only get one ValidatorResult object for "isEmail" with a wrong validation value. There should be two working ValidatorResult objects for "isEmail" and "isBlankOrNull"?!?!
    Are two validation method in the depends-Attribute not allowed (although it is defined in the standard)?
    You can assume, that the used validator class is conform to the given org.apache.commons.TestValidator!
    For any help, thx in advance!
    Greets
    CN

    Hey Aaron,
    Could you post your code for your <field>...</field>?
    Here is an example from: http://www.jsn-server3.com/struts-documentation/userGuide/dev_validator.html
    <field
        property="firstName" indexedListProperty="dependents"
        depends="requiredif">
      <arg0 key="dependentlistForm.firstName.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
    </field>
    <field
        property="dob"
        indexedListProperty="dependents"
        depends="requiredif,date">
      <arg0 key="dependentlistForm.dob.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
    </field>
    <field
        property="coverageType"
        indexedListProperty="dependents"
        depends="requiredif">
      <arg0 key="dependentlistForm.coverageType.label"/>
      <var>
        <var-name>field[0]</var-name>
        <var-value>lastName</var-value>
      </var>
      <var>
        <var-name>field-indexed[0]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-test[0]</var-name>
        <var-value>NOTNULL</var-value>
      </var>
      <var>
        <var-name>field[1]</var-name>
        <var-value>insureDependents</var-value>
      </var>
      <var>
        <var-name>field-test[1]</var-name>
        <var-value>EQUAL</var-value>
      </var>
      <var>
        <var-name>field-value[1]</var-name>
        <var-value>true</var-value>
      </var>
      <var>
        <var-name>field-join</var-name>
        <var-value>AND</var-value>
      </var>
    </field>
    </form>" Which is read as follows: The firstName field is only required if the lastName field is non-null. Since field-indexed is true, it means that lastName must be a property of the same indexed field as firstName. Same thing for dob, except that we validate for date if not blank.
    The coverageType is only required if the lastName for the same indexed bean is not null, and also if the non-indexed field insureDependents is true.
    You can have an arbitrary number of fields by using the [n] syntax, the only restriction is that they must all be AND or OR, you can't mix. "
    Hope that helps,
    Nate

  • Connect to FTP site with Apache commons net FTP client through Proxy

    Hello,
    I am trying to run this simple code to connect to FTP site through a proxy.
    import org.apache.commons.net.ftp.FTP;
    import org.apache.commons.net.ftp.FTPClient;
    public class MyTest {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    System.setProperty("socksProxyHost" ,"10.148.0.131");
    System.setProperty("socksProxyPort", "1080");
    FTPClient ftpClient = new FTPClient();
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    boolean successLogin = ftpClient.login(ftpUserName, ftpPassword);
    if(successLogin)
    System.out.println("success login");
    else
    System.out.println("fail login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("loging out");
    ftpClient.logout();
    System.out.println("disconecting");
    ftpClient.disconnect();
    catch (Exception e) {
    e.printStackTrace();
    I am getting the following error:
    C:\temp\ftp\test>java.exe -cp ./commons-net-ftp-2.0.jar;. MyTest connecting
    java.net.SocketException: Malformed reply from SOCKS server
    at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:87)
    at java.net.SocksSocketImpl.connectV4(SocksSocketImpl.java:265)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:437)
    at java.net.Socket.connect(Socket.java:519)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
    at MyTest.main(MyTest.java:23)
    loging out
    java.lang.NullPointerException
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:471<ftp://FTP.java:471>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:534<ftp://FTP.java:534>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:583<ftp://FTP.java:583>)
    at org.apache.commons.net.ftp.FTP.quit(FTP.java:794<ftp://FTP.java:794>)
    at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:697)
    at MyTest.main(MyTest.java:39)
    I am able to do this using a different FTP client library, ftp4j-1.5.1<ftp://ftp4j-1.5.1> using the following code:
    import it.sauronsoftware.ftp4j.FTPClient;
    import it.sauronsoftware.ftp4j.connectors.SOCKS4Connector;
    public class MyTestFtp4J {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    FTPClient ftpClient = new FTPClient();
    ftpClient.setConnector(new SOCKS4Connector("10.148.0.131", 1080));
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    ftpClient.login(ftpUserName, ftpPassword);
    System.out.println("success login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("disconecting");
    ftpClient.disconnect(true);
    catch (Exception e) {
    e.printStackTrace();
    So I know the proxy settings are correct.
    The java version I used to compile and run my apps is 1.6.0_06 Does anyone can help figure out what is wrong when I use the Apache commons net FTP client?
    Thank you
    Jon

    Is the old AirPort Extreme base station (AEBS)
    configured so that the option to distribute IP
    addresses is DISABLED? If so, configure the new AEBS
    to act as a bridge.
    Are you suggesting I use a set-up with TWO AEBSs? Set up a bridge (not sure how) and then use the old AEBS to connect to the DSL modem and broadcast to the new Extreme which will then be the router to the other computers on the network?
    Do you have any port mapping or default host enabled
    on the old AEBS?
    I do not understand, not do I see these options in the Base Station utitlity; perhaps they are in the FTP options--but that, I'm sorry to say, is not obvious to my inspection.
    Duane, can you give me a few more basic instructions? Thanks
    iMac 17    

  • Can't enhance classes with Apache Commons Logging?

    For some reason enhancer blows on class with
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    private static final Log LOG = LogFactory.getLog(GaoParticipant.class);
    With following exception:
    java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at serp.util.MultiClassLoader.findClass(MultiClassLoader.java:224)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at
    com.solarmetric.meta.CFMetaDataParser.classForName(CFMetaDataParser.java:213
    at
    com.solarmetric.meta.CFMetaDataParser.classForName(CFMetaDataParser.java:188
    at kodo.meta.JDOMetaDataParser.startCollection(JDOMetaDataParser.java:321)
    at
    kodo.meta.JDOMetaDataParser.startClassElement(JDOMetaDataParser.java:194)
    at
    com.solarmetric.meta.CFMetaDataParser.startElement(CFMetaDataParser.java:69)
    at
    com.solarmetric.meta.XMLMetaDataParser.startElement(XMLMetaDataParser.java:3
    54)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
    Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno
    wn Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
    her.dispatch(Unknown Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
    Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
    at com.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:309)
    at com.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:254)
    at com.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:234)
    at
    kodo.meta.JDOMetaDataRepositoryImpl.getMetaDataInternal(JDOMetaDataRepositor
    yImpl.java:175)
    at
    kodo.meta.JDOMetaDataRepositoryImpl.getMetaData(JDOMetaDataRepositoryImpl.ja
    va:129)
    at kodo.enhance.JDOEnhancer.<init>(JDOEnhancer.java:110)
    at kodo.enhance.JDOEnhancer.run(JDOEnhancer.java:2175)
    at kodo.enhance.JDOEnhancer.run(JDOEnhancer.java:2116)
    at kodo.enhance.JDOEnhancer.main(JDOEnhancer.java:2088)
    at peacetech.gao.ccs.tools.Enhance.main(Enhance.java:14)
    Caused by: org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException: Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja
    va:532)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
    va:272)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
    va:246)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
    at peacetech.gao.ccs.jdo.GaoParticipant.<clinit>(GaoParticipant.java:14)
    ... 35 more
    Caused by: org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException: Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryI
    mpl.java:416)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja
    va:525)
    ... 39 more
    Caused by: org.apache.commons.logging.LogConfigurationException: Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryI
    mpl.java:412)
    ... 40 more
    Exception in thread "main" Process terminated with exit code 1

    Have not tried Ant but running main() runs when LOG is not initialized at
    all and blows in both cases below
    1.
    private static Log LOG ;
    static {
    LOG = LogFactory.getLog(Contact.class);
    2
    private static Log LOG = getLog();
    private static Log getLog() {
    return LogFactory.getLog(Contact.class);
    "Marc Prud'hommeaux" <[email protected]> wrote in message
    news:[email protected]...
    Alex-
    Do you see the problem if you just enhance the class from the
    command-line "jdoc" tool?
    Also, if you just don't initialize the log, do you still see the
    problem (e.g., making it a lazy initialization via some static
    getLog() method)?
    In article <[email protected]>, Alex Roytman wrote:
    It is not even ant just a class which I run from under Intellij IDEA
    package peacetech.gao.ccs.tools;
    import kodo.enhance.JDOEnhancer;
    public class Enhance {
    String arr[];
    public static void main(String[] args) throws Exception {
    String root = "D:/projects/gao/ccs/main/java/jdo/classes/";
    System.getProperties().put("kodo.properties", "ccs-jdo.properties");
    JDOEnhancer.main(new String[]{"-te", "true", root +
    "/peacetech/gao/ccs/jdo/package.jdo"});
    "Marc Prud'hommeaux" <[email protected]> wrote in message
    news:[email protected]...
    Alex-
    This seems to be a problem that happens under some classloader
    circumstances.
    Do you have a special <classloader> element for your <enhance> target?
    If so, does it still occur if you remove it (conversely, does it still
    happen if you add in a <classloader> element?
    In article <[email protected]>, Alex Roytman wrote:
    For some reason enhancer blows on class with
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    private static final Log LOG =
    LogFactory.getLog(GaoParticipant.class);
    >>>>
    With following exception:
    java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at serp.util.MultiClassLoader.findClass(MultiClassLoader.java:224)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at
    com.solarmetric.meta.CFMetaDataParser.classForName(CFMetaDataParser.java:213
    at
    com.solarmetric.meta.CFMetaDataParser.classForName(CFMetaDataParser.java:188
    atkodo.meta.JDOMetaDataParser.startCollection(JDOMetaDataParser.java:321)
    at
    kodo.meta.JDOMetaDataParser.startClassElement(JDOMetaDataParser.java:194)
    at
    com.solarmetric.meta.CFMetaDataParser.startElement(CFMetaDataParser.java:69)
    at
    com.solarmetric.meta.XMLMetaDataParser.startElement(XMLMetaDataParser.java:3
    54)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(UnknownSource)
    atorg.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
    Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(UnknownSource)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno
    wn Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
    her.dispatch(Unknown Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
    Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
    atcom.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:309)
    atcom.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:254)
    atcom.solarmetric.meta.XMLMetaDataParser.parse(XMLMetaDataParser.java:234)
    at
    kodo.meta.JDOMetaDataRepositoryImpl.getMetaDataInternal(JDOMetaDataRepositor
    yImpl.java:175)
    at
    kodo.meta.JDOMetaDataRepositoryImpl.getMetaData(JDOMetaDataRepositoryImpl.ja
    va:129)
    at kodo.enhance.JDOEnhancer.<init>(JDOEnhancer.java:110)
    at kodo.enhance.JDOEnhancer.run(JDOEnhancer.java:2175)
    at kodo.enhance.JDOEnhancer.run(JDOEnhancer.java:2116)
    at kodo.enhance.JDOEnhancer.main(JDOEnhancer.java:2088)
    at peacetech.gao.ccs.tools.Enhance.main(Enhance.java:14)
    Caused by: org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException: Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja
    va:532)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
    va:272)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
    va:246)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
    atpeacetech.gao.ccs.jdo.GaoParticipant.<clinit>(GaoParticipant.java:14)
    ... 35 more
    Caused by: org.apache.commons.logging.LogConfigurationException:
    org.apache.commons.logging.LogConfigurationException: Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryI
    mpl.java:416)
    at
    org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.ja
    va:525)
    ... 39 more
    Caused by: org.apache.commons.logging.LogConfigurationException:Class
    org.apache.commons.logging.impl.Log4JLogger does not implement Log
    at
    org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryI
    mpl.java:412)
    ... 40 more
    Exception in thread "main" Process terminated with exit code 1
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • File upload using apache Commons FileUpload problem

    Hi All,
    I have used Commons FileUpload for uploading files from windows to unix machine. I'm able to upload files but I have a problem about the contents of file copied in unix. When i upload files few files containing special characters are not copied correctly in unix instead ascii codes are getting copied/written. Seems to be a problem with character encoding.
    For example symbol "�" is not getting copied correctly in unix. So as new line character to. If anyone has faced such issues kindly provide few pointers on this. Appreciate your guidance.
    Thanks,
    -Aj

    Thanks for the reply.
    I'm using the Commons FileUpload class "FileItem" which holds the filestream data and using function
    code snippet of file upload
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    Iterator it = fileItemsList.iterator();
    while (it.hasNext())
         FileItem fileItemTemp = (FileItem)it.next();
         File saveToFile = new File("newFile");
          fileItem.write(saveToFile ); // write fileItem data to saveToFile.
    } FileItem object takes care of writing data to disk.No idea,how it does internally.
    Thanks,
    -Aj.

Maybe you are looking for