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.