<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Rest Easy MultiPart Support for file upload
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/surein">Suresh Indukuri</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/571955#571955">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I am using RestEasy 2.0.1 GA</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am trying to Upload a file using mutipart</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span>&lt;html&gt;&lt;FORM NAME="InputForm" ACTION="</span><a class="jive-link-external-small" href="http://localhost:8081/Test/helloworld/upload" target="_blank">http://localhost:8081/Test/helloworld/upload</a><span>" METHOD="POST" enctype=multipart/form-data&gt;</span></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;P&gt;&lt;input type=text name="name" size=80&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;P&gt;&lt;input type=file name="filedata" size=80&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;P&gt;&lt;input type="submit" value="Upload File Test"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/FORM&gt;&lt;/html&gt;</div><div> </div><p><span>&lt;html&gt;&lt;FORM NAME="InputForm" ACTION="</span><a class="jive-link-external-small" href="http://localhost:8081/Test/helloworld/upload" target="_blank">http://localhost:8081/Test/helloworld/upload</a><span>" METHOD="POST" enctype=multipart/form-data&gt;</span></p><p>&lt;P&gt;&lt;input type=text name="name" size=80&gt;</p><p>&lt;P&gt;&lt;input type=file name="filedata" size=80&gt;</p><p>&lt;P&gt;&lt;input type="submit" value="Upload File Test"&gt;</p><p>&lt;/FORM&gt;&lt;/html&gt;</p><div> </div><div> </div><div>My Entity class</div><div> </div><div><div>public class FileUploadForm {</div><div> </div><div><span style="white-space: pre;"> </span></div><div> private byte[] filedata;</div><div> </div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; public FileUploadForm() {}</div><div> </div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; public byte[] getFileData() {</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return filedata;</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; }</div><div> </div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; @FormParam("filedata")</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; @PartType("application/octet-stream")</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; public void setFileData(final byte[] filedata) {</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.filedata = filedata;</div><div><span style="white-space: pre;"> </span>&#160;&#160;&#160; }</div><div><span style="white-space: pre;"> </span></div><div>}</div></div><div> </div><div> </div><div>Client Code</div><div> </div><div><div>@Path("/helloworld")</div><div>public class HelloWorldResource {</div><div>&#160; </div><div>&#160; </div><div>&#160; @POST</div><div>&#160; @Path("/upload")</div><div>&#160; @Consumes("multipart/form-data")</div><div>&#160; public Response create(@MultipartForm FileUploadForm form) </div><div>&#160; {</div><div><span style="white-space: pre;"> </span> </div><div><span style="white-space: pre;"> </span>&#160; </div><div><span style="white-space: pre;"> </span>&#160; </div><div><span style="white-space: pre;"> </span>&#160; System.out.println("HI I am ready to upload the file");</div><div><span style="white-space: pre;"> </span>&#160; </div><div><span style="white-space: pre;"> </span>return null;</div><div> </div><div>&#160; } </div><div> </div><div>}</div></div><div> </div><div> </div><div>I am getting 404 in html out as</div><div> </div><div><div style="font-family: Tahoma, Arial, sans-serif; color: black; background-color: white; font-size: 12pt;"><h1 style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: #525d76; font-size: 22px;">HTTP Status 400 - Could not find message body reader for type: class com.sify.resteasy.FileUploadForm of content type: multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi"</h1><hr noshade="noshade" size="1" style="color: #525d76;"/><p style="font-family: Tahoma, Arial, sans-serif; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; color: black; font-size: 12px; background-position: initial initial; background-repeat: initial initial;"><strong style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: #525d76;">type</strong> Status report</p><p style="font-family: Tahoma, Arial, sans-serif; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; color: black; font-size: 12px; background-position: initial initial; background-repeat: initial initial;"><strong style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: #525d76;">message</strong> <span style="text-decoration: underline;">Could not find message body reader for type: class com.sify.resteasy.FileUploadForm of content type: multipart/form-data;boundary="----WebKitFormBoundaryBZcXdH72lf2GpIUi"</span></p><p style="font-family: Tahoma, Arial, sans-serif; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: white; color: black; font-size: 12px; background-position: initial initial; background-repeat: initial initial;"><strong style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: #525d76;">description</strong> <span style="text-decoration: underline;">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").</span></p><hr noshade="noshade" size="1" style="color: #525d76;"/><h3 style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: #525d76; font-size: 14px;">Apache Tomcat/7.0.4</h3></div></div><div> </div><div> </div><div> </div><div>and in java code</div><div> </div><div>------------------------------------------------</div><div><div>19812 [http-8081-exec-5] ERROR org.jboss.resteasy.core.SynchronousDispatcher - Failed executing POST /helloworld/upload</div><div>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"</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.MessageBodyParameterInjector$ReaderUtilityImpl.createReaderNotFound(MessageBodyParameterInjector.java:75)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:106)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:93)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:146)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:114)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:252)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:217)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:206)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:514)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:491)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:120)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:200)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:48)</div><div><span style="white-space: pre;"> </span>at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:43)</div><div><span style="white-space: pre;"> </span>at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:203)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)</div><div><span style="white-space: pre;"> </span>at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)</div><div><span style="white-space: pre;"> </span>at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)</div><div><span style="white-space: pre;"> </span>at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)</div><div><span style="white-space: pre;"> </span>at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:237)</div><div><span style="white-space: pre;"> </span>at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)</div><div><span style="white-space: pre;"> </span>at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</div><div><span style="white-space: pre;"> </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</div><div><span style="white-space: pre;"> </span>at java.lang.Thread.run(Thread.java:619)</div></div><div> </div><div> </div><div> </div><div> </div><div>i need some help to fix this issue</div><div> </div><div>Regards,</div><div> </div><div>Suresh</div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/571955#571955">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>