Note that there are some explanatory texts on larger screens.

plurals
  1. POResteasy multipart/data-form file upload on GAE
    text
    copied!<p>I'm trying to use resteasy 2.0.1.GA to upload a form with a file in it into GAE application, using the method advised at <a href="https://stackoverflow.com/questions/2637017/how-do-i-do-a-multipart-form-file-upload-with-jax-rs">How do I do a multipart/form file upload with jax-rs?</a></p> <p><strong>Index.html</strong></p> <pre><code>&lt;form action="/rest/upload" method="post" enctype="multipart/form-data"&gt; &lt;input type="text" name="name" /&gt; &lt;input type="file" name="file" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p><strong>Rest.java</strong></p> <pre><code>@Path("") public class Rest { @POST @Path("/rest/upload") @Consumes("multipart/form-data") public String postContent(@MultipartForm UploadForm form) { System.out.println(form.getData().length); System.out.println(form.getName()); return "Done"; } } </code></pre> <p><strong>UploadForm.java</strong></p> <pre><code>public class UploadForm { private String name; private byte[] data; @FormParam("name") public void setPath(String name) { this.name = name; } public String getName() { return name; } @FormParam("file") public void setContentData(byte[] data) { this.data = data; } public byte[] getData() { return data; } } </code></pre> <p>But I'm getting the following error message (probably due to the RESTEasy Provider's implmenetation that uses temporary files to handle the input stream):</p> <pre><code>HTTP ERROR 500 Problem accessing /files/service/upload. Reason: java.io.FileOutputStream is a restricted class. Please see the Google App Engine developer's guide for more details. Caused by: java.lang.NoClassDefFoundError: java.io.FileOutputStream 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.james.mime4j.storage.TempFileStorageProvider$TempFileStorageOutputStream.&lt;init&gt;(TempFileStorageProvider.java:117) at org.apache.james.mime4j.storage.TempFileStorageProvider.createStorageOutputStream(TempFileStorageProvider.java:107) at org.apache.james.mime4j.storage.ThresholdStorageProvider$ThresholdStorageOutputStream.write0(ThresholdStorageProvider.java:113) at org.apache.james.mime4j.storage.StorageOutputStream.write(StorageOutputStream.java:119) at org.apache.james.mime4j.codec.CodecUtil.copy(CodecUtil.java:43) at org.apache.james.mime4j.storage.AbstractStorageProvider.store(AbstractStorageProvider.java:57) at org.apache.james.mime4j.message.BodyFactory.textBody(BodyFactory.java:167) at org.apache.james.mime4j.message.MessageBuilder.body(MessageBuilder.java:148) at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:101) at org.apache.james.mime4j.message.Message.&lt;init&gt;(Message.java:141) at org.apache.james.mime4j.message.Message.&lt;init&gt;(Message.java:100) at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:76) at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.readFrom(MultipartFormAnnotationReader.java:55) at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:46) at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108) at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:111) at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:93) at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:146) at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:114) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:252) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:217) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:206) at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:514) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:491) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:120) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:200) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:48) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:43) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ... </code></pre> <p>Has anyone encountered this issue with GAE and RESTEasy? Has anyone solved it? I couldn't find any mentioning for this issue anywhere. Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload