Reputation: 21
I am trying to route HttpServletRequest to another microservice where request may contain multi-part request or any normal request. but while sending I am getting the below error.
Note: I dont want to modify the request as I am trying to write some generic method.
public Object doPostCall(HttpServletRequest request, String requestURL, String rootURL)
throws URISyntaxException, IOException, ServletException {
RestTemplate restTemplate = new RestTemplate();
final String url = rootURL + requestURL;
uri = new URI(url);
try {
result2 = restTemplate.postForEntity(uri, request, Object.class);
System.out.println("after service call" + result2);
} catch (RestClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result2;
}
com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
No serializer found for class java.util.Collections$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.web.multipart.support.StandardMultipartHttpServletRequest["request"]->org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper["request"]->org.apache.catalina.connector.RequestFacade["attributeNames"])
Even I have tried setting this in property file. spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
, but it didn't work
My Consume controller is like below:
@PostMapping(value = "/v1/upload/{moduleName}/{fileType}", produces = "application/json")
public ResponseEntity<Object> uploadFiles(@RequestPart("file") List<MultipartFile> inputFileList,
@RequestParam(value = "createdBy", required = false) String createdBy, @PathVariable String moduleName,
@RequestParam(value = "catalogId", required = false) String catalogId,
@RequestParam(value = "catalogName", required = false) String catalogName, @PathVariable String fileType) {
Upvotes: 2
Views: 9551
Reputation: 156
Try annotating your entity class with @JsonIgnoreProperties("hibernateLazyInitializer")
Upvotes: 3