I have a controller springthat takes a class named FileUploadBeanon POST. The controller method is as follows:
First controller :
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<byte[]> uploadFile(final FileUploadBean fileUploadBean) throws IOException {
}
One of the properties FileUploadBeanis of type MultipartFile.
Now I'm trying to add some kind of shell controller (which will run on another server) that also accepts FileUploadBeanand simply redirects the request to the first controller:
The second (wrapping) controller :
@RequestMapping(value="/upload", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<byte[]> uploadImage(final FileUploadBean fileUploadBean) throws IOException {
ResponseEntity<byte[]> response = restTemplate.postForEntity([first controller url here], fileUploadBean, byte[].class);
return response;
}
When I send a request to the first controller, I get:
org.springframework.http.converter.HttpMessageNotWritableException:
JSON: java.io.FileDescriptor , BeanSerializer ( , SerializationFeature.FAIL_ON_EMPTY_BEANS)) ( : com.outbrain.images.beans.FileUploadBean [ "" ] → org.springframework.web.multipart.commons.CommonsMultipartFile [ "fileItem" ] → org.apache.commons.fileupload.disk.DiskFileItem [ "InputStream" ] → java.io.FileInputStream [ "FD" ]); com.fasterxml.jackson.databind.JsonMappingException: java.io.FileDescriptor , BeanSerializer ( , SerializationFeature.FAIL_ON_EMPTY_BEANS)) ( : com.outbrain.images.beans.FileUploadBean [ "" ] → org.springframework.web.multipart.commons.CommonsMultipartFile [ "fileItem" ] → org.apache.commons.fileupload.disk.DiskFileItem [ "InputStream" ] → java.io.FileInputStream [ "FD" ]) org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.writeInternal
?