Help on file upload

I am using apache fileupload and have following code.
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = new ArrayList() ;
try {
     items = upload.parseRequest(request);
} catch (FileUploadException fue) {
     System.out.println("Error uploading file: " + fue.toString());
Iterator iter = items.iterator();
while (iter.hasNext()) {
     FileItem item = (FileItem);
     if (!item.isFormField()) {
          String name = item.getFieldName();
          String value = item.getString();
     } else {
          String name = item.getFieldName();
          String value = item.getString();
     System.out.println("Found field " + name + " and value " + value) ;
I get the following error when I run it. The error is pointing to code underlined (_ServletFileUpload upload = new ServletFileUpload(factory);_). I have all apache required files as part of WEB_INF/lib. As you see the error is pointing to NoSuchMethodError. I wonder if any one one come across this error and how was it resolved. I appreciate your help.
Error 500--Internal Server Error
java.lang.NoSuchMethodError: org.apache.commons.fileupload.FileUpload.<init>(Lorg/apache/commons/fileupload/FileItemFactory;)V
     at org.apache.commons.fileupload.servlet.ServletFileUpload.(
     at javax.servlet.http.HttpServlet.service(
     at javax.servlet.http.HttpServlet.service(
     at weblogic.servlet.internal.ServletStubImpl$
     at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
     at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
     at weblogic.servlet.internal.WebAppServletContext$
     at weblogic.servlet.internal.WebAppServletContext.invokeServlet(
     at weblogic.servlet.internal.ServletRequestImpl.execute(
     at weblogic.kernel.ExecuteThread.execute(
Thank you,

java.lang.NoSuchMethodError: org.apache.commons.fileupload.FileUpload.<init>(Lorg/apache/commons/fileupload/FileItemFactory;)V
     at org.apache.commons.fileupload.servlet.ServletFileUpload.( the JAR's in all classpaths. There are somewhere two JAR's of the FileUpload API but they are from different versions. Your code is compiled against the right version, but runt against the wrong version where this method is missing. Start checking the classpath of the application server.

Similar Messages

  • HELP! File Upload Servlet and Internet Explorer

    Hello people. I hope this is an easy problem to solve...
    I have a servlet upload program that works using Mozilla browser (, but for some reason it doesn't work using Microsoft IE. The servlet is also using the servlet upload API from Apache (commons).
    I'm using IE version 6.0.2800.1106 in a Win98SE host computer. I get a cannot find path specified error message (see below). At work, I also get the same error message using IE, but don't know what version. The OS is XP. Unfortunately, at work, I can't install Mozilla browser (or any software-company policy) to see if Mozilla works there too. I would've like to have tested to see if the upload program worked on Mozilla on a truly remote computer.
    So I figured, it must be a IE configuration issue, but darn it!! I began by resetting IE to default settings, but still have the problem, I played around with several different combinations of settings in "Tools"-->"Internet Options...", and I still get the error message. Someone PLEASE HELP ME!!!
    Dunno, if it will help, I've also pasted the upload servlet source code below and the html file that's calling the upload servlet, but you still need the Apache commons file upload API.
    Trust me on this one folks, for some reason it works for Mozilla, but not for IE. With IE, I can at least access web server, and therefore, the html file that calls the upload servlet , so I don't think it's a Tomcat configuration issue (version 5.0). I actually got the code for the file upload servlet from a book relatively new in the market (printed in 2003), and it didn't mention any limitations as far as what browser to use or any browser configuration requirements. I have e-mailed the authors, but they probably get a ton of e-mails...
    Anyone suggestions?
    Meanwhile, I will try to install other free browsers and see if the file upload program works for them too.
    "HTTP Status 500 -
    type Exception report
    description The server encountered an internal error () that prevented it from fulfilling this request.
    javax.servlet.ServletException: C:\TOMCAT\webapps\MyWebApps\files\C:\WINDOWS\Desktop\ (The system cannot find the path specified)
    root cause C:\TOMCAT\webapps\MyWebApp\files\C:\WINDOWS\Desktop\ (The system cannot find the path specified) Method)
    note The full stack trace of the root cause is available in the Tomcat logs.
    Apache Tomcat 5.0.16"
    FILE UPLOAD SERVLET source code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.commons.fileupload.*;
    import java.util.*;
    public class FileUploadCommons extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    out.print("File upload success. <a href=\"/MyWebApp/files/");
    out.print("\">Click here to browse through all uploaded ");
    ServletContext sc = getServletContext();
    String path = sc.getRealPath("/files");
    org.apache.commons.fileupload.DiskFileUpload fu = new
    try {
    List l = fu.parseRequest(request);
    Iterator i = l.iterator();
    while (i.hasNext()) {
    FileItem fi = (FileItem);
    fi.write(new File(path, fi.getName()));
    catch (Exception e) {
    throw new ServletException(e);
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    doPost(request, response);
    HTML PAGE that calls the upload servlet:
    <title>Example HTML Form</title>
    <p>Select a file to upload or browse
    currently uploaded files.</p>
    <form action="http://##.##.##.####/MyWebApp/FileUploadCommons"
    method="post" enctype="multipart/form-data">
    File: <input type="file" name="file"><br>
    <input value="Upload File" type="submit">
    Thanks in advance for any assistance.

    I'm guessing what is happening is that Mozilla tells the servlet "here comes the file". The servlet builds a file name for it:
        String path = sc.getRealPath("/files");
        // path is now C:\TOMCAT\webapps\MyWebApps\files\
        fi.write(new File(path, fi.getName()));
        // append to "path", making it C:\TOMCAT\webapps\MyWebApps\files\myfile.zipIE, however, tells "here comes the file C:\WINDOWS\Desktop\". Now imagine what the path+filename ends up being...
    So what you want to do is something along the lines of (assuming Windoze):
    public static String basename(String filename)
        int slash = filename.lastIndexOf("\\");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // I think Windows doesn't like /'s either
        int slash = filename.lastIndexOf("/");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // In case the name is C:foo.txt
        int slash = filename.lastIndexOf(":");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        return filename;
        fi.write(new File(path, basename(fi.getName()));
        ....You can make the file name check more bomb proof if security is an issue. Long file names trying to overflow something in the OS, NUL characters, Unicode, forbidden names in Windos (con, nul, ...), missing file name, ...

  • Help with File Upload manually

    Hi Experts,
    I need code to upload a file without using the upload UI Element. we have our terms and conditions which has to be signed by the user and once the user signs and clicks the next button to go to the next page, I generate a pdf with the time stamp of when the user signed and upload it to ECC. here i can not use the File upload UI Element but have to upload it automatically to ECC.
    Can any one help me out with this please.

    I dont know why you need to to upload the file for this requirement. You can simply store the user id and the timestamp in portal database table or in a ECC z table.
    In case you definitely need to upload the file then you can use KM API to uploadthe file to portal KM folder
    but you need not use the upload feature in the example, instead just get the data from wd context and upload to KM.

  • Help with file upload

    I was wondering if there's a kind of lightweight component for uploading files in JSF. I tried Oracle's ADF Faces, but besides it being a couple of megs it screwed up the HTML code in my pages and some Javascript functions wouldn't work. I saw a post here where someone created his own component but as it will have minor use in my app i'd like something packed so I can just add it on.
    I only need to upload one file in my app, so maybe it's better to use a regular JSP and Servlet approach for this one. Suggestions or comments would be appreciated, thanks..

    I followed the examples in the chapter, but I needed a .tld file so I created one:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    <display-name>JSF File Upload</display-name>
    <description>File upload library fo JSF</description>
    Uploads the file.
    Its in WEB-INF and declared in web.xml, but I'm getting an error:
    javax.faces.FacesException: Expression Error: Named Object: 'com.corejsf.Upload' not found.
    There's no such class in the component, but the UploadTag returns "com.corejsf.Upload" in both getRenderedType() and getComponentType().
    If someone has this working; help please!!

  • Help with file upload Actionscript

    I am trying to do a file upload using Actionscript and a
    modified version of the tutorial found at:
    When I call the function
    should that go to that page once it finishes, or how do I
    force Flash to redirect the browser to that page passing the
    uploaded file?
    What am I missing here, or what else would anyone need to
    help me?
    Any help would be greatly appreciated thanks in advance!
    Joshua Abts

    It seems as though the page is not being loaded after the
    ActionScript upload command.
    Why would my PHP script not be called from the upload
    ActionScript? I even just did a simple one line redirect to see if
    the PHP script was even being called and it didn't work.
    What is the basis for getting the script to send the picture
    to the PHP script as a post and using the $_FILES array?

  • Help on File Upload on ATG Dynamo 5.6 (Servlet 2.2)

    I am using Apache Common FileUpload to upload a file on the server. It works well on Tomcat . I tried to port the same code on ATG Dynamo 5.6.1, I could not upload the files. After going deep into the problem, I got to know that Apache FileUpload has a dependancy of Servlet 2.3 Specs compliance.
    While I checked the version of Servlet on ATG, it was 2.2.
    Could somebody help me with the same.
    I need some file upload utility that would work on ATG Dynamo.
    Or atleast a way out would do.
    Thanks and regards.....

    Try to obtain an older version of the commons FileUpload utility if available, which is compatible with your desired version or you can use another utility that supports Servlets 2.0 provided by Oreilly Package...
    The class MultipartRequest authored by oreilly that included in the package holds the whole nasty behind the scenes, here you are the link for the docs
    And you can find the package, examples and the sources here
    Best Regards,
    mohammed Sleem

  • Need help for file upload - reposted for Steve Muench

    Hi Steve,
    I have been involved developing a web application that requires a file upload operation. I have studied your example on Upload Text File and Image Example in the Not Yet Documented ADF Sample Applications section. I got the file upload part worked but could not get the original file name to populate the name field..i.e. if I upload myFile.txt to the database, the name field will be myFile.txt (not the name enter by user). Is there a way to capture the filename info? or is it possible to do so within ADF framework? I am using ADF/Struts/JSP with ORDDoc data type. Thanks very much.

    Hello Nani,
    You need to change any settings in 'FILE' transaction. This transaction is used to set up Logical file paths. ( In general it will be set already for your system).
    You can use the following code.
                                                    VALUE 'EHS_IMP_SOURCES'.
      DATA:      L_EMERGENCY_FLAG            TYPE C.
      data : X_RCGIEDIAL LIKE  RCGIEDIAL occurs 0 with HEADER LINE.
      read the default pathname on application server
                CLIENT                  = SY-MANDT
                  OPERATING_SYSTEM        = SY-OPSYS
                parameter_1             = ' '
                PARAMETER_2             = ' '
                USE_PRESENTATION_SERVER = ' '
                WITH_FILE_EXTENSION     = ' '
                USE_BUFFER              = ' '
                  EMERGENCY_FLAG          = L_EMERGENCY_FLAG
                  FILE_FORMAT             = L_FILE_FORMAT
                  FILE_NAME               = X_RCGIEDIAL-IEFILE
                  FILE_NOT_FOUND          = 1
                  OTHERS                  = 2.
        write :/ 'file format', L_FILE_FORMAT,
               / 'file name', X_RCGIEDIAL-IEFILE.

  • Help with file uploader, php script, Windows Authentication

    I am trying to setup a really basic web-based file uploader that I will expand upon later. I have the flex application working well enough (very basic). However, I have a php script in a secure folder using windows authentication. When I try to send the file to the script, it doesn't seem to like my credentials, and refuses to do anything. I do not get an error message; just nothing happens.
    My questions are:
    Does anybody know where I should've looked before posting this thread?
    Do I even have PHP set up correctly? (At first I just made a txt file and put a .php extension on it, then I tried to setup PHP on the server, but it was a little confusing for me)
    Is Windows Authentication the problem?
    I do plan on implementing SQL Server in the future (to keep track of Files and user-defined attributes for files), but I do not want to store the files in SQLserver, just their pathnames.
    Is there a simple way to use ColdFusion (for free) to acheive this end?
    I am somewhat experienced at coding applications, but am totally new to server-side scripts.
    This is my php script:
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $fileName = $_FILES['Filedata']['name'];
    $fileSize = $_FILES['Filedata']['size'];
    move_uploaded_file($tempFile, "./" . $fileName);
    This is my flex application:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx=""
                      xmlns:mx="library://" minWidth="955" minHeight="600">
         private var fileRef:FileReference
         private var uploadFilePath:String
         private function selectFile():void
              fileRef = new FileReference();
              fileRef.addEventListener(Event.SELECT, fileRef_select);
         private function fileRef_select(evt:Event):void
              fileRef.upload(new URLRequest("http://SERVERLOCATION/PDFUploader.php"));
         <s:Button top="30" left="5" label="Browse" click="selectFile()"/>
    Thanks to any who take the time to respond.

    Hey, so far all I have found is this tutorial.. I'm about to try it out

  • Help:simple file upload example not working

    Request input on what's wrong with this -
    Using JDeveloper 10G.
    1) I created a simple jsp file upload file using the OJSP
    File Access Tag library options. With empty JSP file,I
    dropped in the httpUploadForm and the httpUpload tags.
    Now when I run this I get the following error stack on
    the web page.
    javax.servlet.jsp.JspTagException: Posted content type isnt multipart/form-data at oracle.jsp.webutil.fileaccess.tagext.HttpUploadTag.doStartTag( test4.jspService(test4.jsp:10)[test4.jsp]
    2)Now if I use a simple JSP without the tag library - the
    page fails to display. Found that commenting out the
    line "upbean.upload()" lets the page run and atleast
    show me the upload form. What's wrong with this
    standard example from the OC4J documentation -
    <%@ page import =
    oracle.jsp.webutil.fileaccess.*;" language="java" session="true" contentType="text/html;charset=windows-1252"
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <% String userdir = "mydir"; %>
    <form action="pUpload.jsp" ENCTYPE="multipart/form-data" method=POST>
    File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
    <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Send">
    <jsp:useBean id="upbean" class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
    <jsp:setProperty name="upbean" property="destination" value="<%= userdir %>" />
    <% upbean.setBaseDir(application, request);

    It's not clear from your post, but are you aware that the
    documentation is really showing multiple files?
    The doc examples are based on the ones you can try out by downloading the ojspdemos.ear file.
    They use discrete steps. For example, the fileUploadIndex.html contains the following
    This will call the form and set the action in the form to call the tag upload jsp file. The form will do the multi-part post and the tag upload file does display the text after the <upload:httpUpload> tag. I just re-ran the example to be sure.
    The same basic mechanism applies to the upload bean. That is it is called via:
    This is the only way that these can work because the upload code (beans & tags) both require a multi-part post. I hope this helps

  • Need help on File uploading in JSF

    Hi All,
    i have to upload some document into IBM DB2 Content Management using JSF Portlet.
    Is it possible to upload a document( in my case it is an image) using JSF Portlet into IBM DB2 Content Management? and also i need to keep the reference of the uploaded document in DB2 database.
    i need some sample code to do this.
    the tools i am using are
    RAD 6.0 as IDE
    IBM DB2 Content Managener 8.3
    IBM DB2 8.2
    its an urgent requirement please help me out in this regard

    If it's possible in Portlets i don't know, but in JSF is possible with the Tomahawk component to upload files.
    Try it.

  • Need help w/ file uploading!

    hi! i'm writing a JSP where the client has the possibility to upload image-files
    to the server.. anyone have a good way to it? and if so how?
    if you are referring me to some java-classes i would like to get proper
    information on how to append them in the best way possible...
    i've heard about the MaybeUpload package by Weft but there's one thing i
    don't understand... in the form you use the <input file=""> tag, but how do i
    obtain the file? if use request.getParameter() i would get the path, wouldn't i??
    hope you can help me out!

    read this.

  • Help! File Upload Portlet

    Come on Plumtree Support, I know you can do it...
    How do I write a portlet that will upload a file and save it in a designated Knowledge Directory folder that the user picks from an existing Knowledge Directory folder list ? In addition, can I also perform the document submission and automatically approve the document?

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • Urgent help needed---File upload using struts

    can anyone helpme out on how to perform FileUpload operation using struts

    You should use<html:file> tag for uploading file through struts. And make sure that in form bean u need to manipulate this property with FormFile type. provide getter and setter in form bean for this one and manipulate it in your action class.
    let me know if u have any further issue..

  • JSF Calendar/ File Upload

    Can any one of you suggest me any tutorial about Calendar function? How to add the calendar component into Studio Creator? Highly appreciate your help.
    Also, I need help on File upload.

    Thanks for the information. But I have a question on Calendar component . I want the Calendar component to be open when user wants to enter a date. Otherwie it looks akward in a page to keep the component visible all the time. How do I do that? What I am thinking is, i want to make this small and upon clicking it will open the calendar and select date. Thanks for your help in advance.
    About Fileupload
    Do I have to copy any jar file from MyFaces. I am using SUN Studio Creator. Do I have to import anything?

  • Help!! uploaded files in the application is not getting applied

    Hi all,
    I have 2 css file, 1 image file and 3 javascript files uploaded.
    once when i clear the browser cache and start the application it works fine.
    ie all files are getting applied in the application.
    then when the page is refreshed in the middle of the application by clicking a button (ie i have search report, by clicking a button according to the data in the form, report will get displayed).
    can any one please help me? I really need to get this work.

    My point is that if you didn't resolve the problem you were working in the other thread (and getting help from others there and keeping them informed of your progress there) then it's a bad thing to abandon that thread and mislead those who were following it.
    I suggest you announce that this thread is a mistake and resume work in the other thread.
    That way all the resources will be applied in a central place.

Maybe you are looking for

  • The computer my iTunes account was locked to no longer works

    As the title says my computer that has all my tv shows and that on no longer works. I was reading when I bought the tv series and that, that its locked to one computer only. So what happens now that its broken? Do I have to rebuy everything when I ge

  • Reader XI crashes on Macosx when opening shared document

    I am unable to open any of our documents for shared review on my Mac.  100% of the time it results in a crash.  I have tried uninstalling, reinstalling, removing Adobe prefs from the Library directories. The directory that holds the shared documents

  • 20" Cinema dispaly, brightness control w/ PC

    I have just purchased the 20" Cinema display to use with a PC. It works and looks great, however the brightness controls and on/off buttons don't work. I read there is a setting to access using Apple Preferences, however I can't figure out using a PC

  • Error message : Info Idoc missing ;database system

    I am  trying to load the data from database system  oracle ,the data was successfully loaded into psa , but can’t able to load the data into ods from psa . Data in psa is all green without any errors , as  info idocs are missing its not letting  to l

  • Spotlight not finding files that definitely exist.

    I have spent the day backing up and syncing. I have an epson P4000 (PSD). I also have two external drives (yes, this may be overkill, but I never do it). The P4000 is backed up and synced to both drives. When I do a search for all files with a .RAW e