Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:21:10+00:00 2026-05-30T19:21:10+00:00

I developing a web application using GWT where i am trying to upload a

  • 0

I developing a web application using GWT where i am trying to upload a file . My servlet is working fine.

but when i use DiskFileItemFactory() it gives me error.

if some one can correct my code or tell what is missing in code.

 protected void doPost(HttpServletRequest request, 
            HttpServletResponse response) 
                    throws ServletException, IOException { 

         response.setContentType("text/plain"); 
        FileItem uploadItem = getFileItem(request); 
        if (uploadItem == null) { 
          response.getWriter().write("NO-SCRIPT-DATA"); 
          return; 
        } 
        byte[] fileContents = uploadItem.get(); 
        //TODO: add code to process file contents here. We will just print 

                    response.getWriter().write(new String(fileContents)); 
}

private FileItem getFileItem(HttpServletRequest request) {
    // TODO Auto-generated method stub
    FileItemFactory factory = new DiskFileItemFactory(); 
    ServletFileUpload upload = new ServletFileUpload(factory); 
    try { 
      List items = upload.parseRequest(request); 
      Iterator it = items.iterator(); 
      while (it.hasNext()) { 
        FileItem item = (FileItem) it.next(); 
        if (!item.isFormField() 
            && "uploadForm".equals(item.getFieldName())) { 
          return item; 
        } 
      } 
    } catch (FileUploadException e) { 
      return null; 
    } 
    return null;
} 

ERROR

 java.lang.NoClassDefFoundError: java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.apache.commons.fileupload.disk.DiskFileItem.<clinit>(DiskFileItem.java:109)
at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:199)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:361)
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
at com.server.FileUpload.getFileItem(FileUpload.java:101)
at com.server.FileUpload.doPost(FileUpload.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

Edited: Working Code

    try {
            ServletFileUpload upload = new ServletFileUpload();
            response.setContentType("text/plain"); 


            FileItemIterator iterator = upload.getItemIterator(request);

            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();

                InputStream stream = item.openStream();

                if (item.isFormField()) {
                    log.warning("Got a form field: " + item.getFieldName()  + " " +item);



                } else{
                    log.warning("Got an uploaded file: " + item.getFieldName() +
                              ", name = " + item.getName());
                    int len;
                    byte[] buffer = new byte[8192];
                    while ((len = stream.read(buffer, 0, buffer.length)) != -1) {

                      response.getOutputStream().write(buffer, 0, len);

                    }

                }

            }
    } catch (FileUploadException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:21:11+00:00Added an answer on May 30, 2026 at 7:21 pm

    You cannot use RMI in GAE – if you want something similar, take a look at this question.

    But from your code it doesn’t seem you need to use RMI at all – why are you using it? Ain’t you just going to process and store it somewhere?

    If you are going to store large files (up to 32MB), use the Blobstore API.

    If you know you’ll only have files <1MB, you can store them using JDO/JPA and a normal Entity that contains a Blob – this option will also allow you to easily pre-process the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use tomcat. I am developing a web application using struts2, and I use
I'm developing a web UI using GWT. While working only with the widgets I
I am developing web application using asp.net, but i want to work on asp
we are developing an web application using GWT 2.4, Errai 1.3.2. It is running
I have some doubts, i m developing a web application in GWT using MVP
I am using the GWT for developing my web application and would like to
I am developing a web application using gwt and gwtp. I can get a
I'm developing a web- application using NHibernate. Can you tell me how to write
I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have
I am developing an web application using php. One of the requirement is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.