Search code examples
javagoogle-app-engineapache-commons

rmi error in google app


I dont get the error when I use the following line

    FileItemIterator it = servletFileUpload.getItemIterator(request);

I get it when I use following line

    List fileItemsList = servletFileUpload.parseRequest(request);

How are they different and How is rmi related to servletFileUpload.parseRequest(request);?

Error: Caused by:

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.(DiskFileItem.java:103)
    at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:196)
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:358)
    at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
    at morefile.CopyOfUploadApp.doPost(CopyOfUploadApp.java:147)

Context: A file upload application using Apache commons lib on google apps.


Solution

  • Commons FileUpload (1.2.1) is only semi-compatible with GAE. Only streaming API is supported but not the traditional API beacuse a local filesystem is not made available by GAE. In the stacktace, I see usage of DiskFileItem, which basically writes the uploaded file locally and deletes it later.

    See the section under Apache Commons FileUpload at GAE and support for Java frameworks

    Here's the streaming API usage.