Suresh Indukuri [
http://community.jboss.org/people/surein] created the discussion
"Rest Easy MultiPart Support for file upload"
To view the discussion, visit:
http://community.jboss.org/message/571955#571955
--------------------------------------------------------------
I am using RestEasy 2.0.1 GA
I am trying to Upload a file using mutipart
<html><FORM NAME="InputForm" ACTION="
http://localhost:8081/Test/helloworld/upload
http://localhost:8081/Test/helloworld/upload" METHOD="POST"
enctype=multipart/form-data>
<P><input type=text name="name" size=80>
<P><input type=file name="filedata" size=80>
<P><input type="submit" value="Upload File Test">
</FORM></html>
<html><FORM NAME="InputForm" ACTION="
http://localhost:8081/Test/helloworld/upload
http://localhost:8081/Test/helloworld/upload" METHOD="POST"
enctype=multipart/form-data>
<P><input type=text name="name" size=80>
<P><input type=file name="filedata" size=80>
<P><input type="submit" value="Upload File Test">
</FORM></html>
My Entity class
public class FileUploadForm {
private byte[] filedata;
public FileUploadForm() {}
public byte[] getFileData() {
return filedata;
}
@FormParam("filedata")
@PartType("application/octet-stream")
public void setFileData(final byte[] filedata) {
this.filedata = filedata;
}
}
Client Code
@Path("/helloworld")
public class HelloWorldResource {
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public Response create(@MultipartForm FileUploadForm form)
{
System.out.println("HI I am ready to upload the file");
return null;
}
}
I am getting 404 in html out as
h1. HTTP Status 400 - Could not find message body reader for type: class
com.sify.resteasy.FileUploadForm of content type:
multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi"
----
*type* Status report
*message* Could not find message body reader for type: class
com.sify.resteasy.FileUploadForm of content type:
multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi"
*description* The request sent by the client was syntactically incorrect (Could not find
message body reader for type: class com.sify.resteasy.FileUploadForm of content type:
multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi").
----
h3. Apache Tomcat/7.0.4
and in java code
------------------------------------------------
19812 [http-8081-exec-5] ERROR org.jboss.resteasy.core.SynchronousDispatcher - Failed
executing POST /helloworld/upload
org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type:
class com.sify.resteasy.FileUploadForm of content type:
multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi"
at
org.jboss.resteasy.core.MessageBodyParameterInjector$ReaderUtilityImpl.createReaderNotFound(MessageBodyParameterInjector.java:75)
at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:106)
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:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:203)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:237)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
i need some help to fix this issue
Regards,
Suresh
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/571955#571955]
Start a new discussion in JBoss Web Services at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]