2

Getting JAX-RS entity provider does not currently exist. exception when I tried to upload a file.. How could I register any missed provider?

What is the best approach to upload a file using Apache Wink client and media type is multipart/form-data.

    /* BufferedOutMultiPart requestEntity = new BufferedOutMultiPart();
    requestEntity.setBoundary("Simple-boundary-weqiftugcs");
    OutPart outPart = new OutPart();
    outPart.setBody(file);
    outPart.setContentType(MediaType.MULTIPART_FORM_DATA);
    outPart.addHeader("Content-Transfer-Encoding", "binary");
    outPart.addHeader("Content-Disposition", "form-data; name=\"uploadedFile\";");
    requestEntity.addPart(outPart); */

    MultipartEntity multiPartEntity = new MultipartEntity();
    FileBody fileBody = new FileBody(file);
    multiPartEntity.addPart("uploadFile", fileBody);

    ClientConfig clientConfig = new ClientConfig();
    RestClient restClient = new RestClient(clientConfig);

    Resource restResource = restClient.resource(serviceURL);
    restResource.accept("*/*");
    restResource.contentType(MediaType.MULTIPART_FORM_DATA);
    restResource.post(multiPartEntity);

Exception in thread "main"

org.apache.wink.client.ClientRuntimeException:java.lang.RuntimeException: java.lang.RuntimeException: A javax.ws.rs.ext.MessageBodyWriter implementation was not found for the class org.apache.http.entity.mime.MultipartEntity type and multipart/form-data media type. Verify that all entity providers are correctly registered. Add a custom javax.ws.rs.ext.MessageBodyWriter provider to handle the type and media type if a JAX-RS entity provider does not currently exist.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
John1987
  • 21
  • 2
  • I'm not familiar with it and I can't offer an answer, but I'd like to rant that they are making it too complicated. my own [http client](http://bayou.io/release/0.9/docs/http/Http_Client.html#Form_Submission) makes it much easier. – ZhongYu May 20 '15 at 00:41

0 Answers0