Announcement Announcement Module
No announcement yet.
RestClientException:Cannot extract response: no Content-Type found Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RestClientException:Cannot extract response: no Content-Type found

    We are using Spring 3.1.2.We have some REST web services which produce JSON reponse.We are using Spring REST Template to consume the service.

    But randomly ,5-10% requests are randomly giving the exception:Cannot extract response: no Content-Type found in ResTemplate exchange method.It is totally random ,there is no pattern.HTTPMonitor shows that whenwe are getting the exception, the content type in response header is not set by the service.

    org.springframework.web.client.RestClientException : Could not extract response: no suitable HttpMessageConverter found for response type [org.onesync.common.dto.uma.UserDTO] and content type [application/octet-stream]
    at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract
    at org.springframework.web.client.RestTemplate$Respon seEntityResponseExtractor.extractData(RestTemplate .java:627)
    at org.springframework.web.client.RestTemplate$Respon seEntityResponseExtractor.extractData(RestTemplate .java:1)
    at org.springframework.web.client.RestTemplate.doExec ute(
    at org.springframework.web.client.RestTemplate.execut e(
    at org.springframework.web.client.RestTemplate.exchan ge(
    at org.onesync.pdm.uma.user.main.NextGenServicesClien tMain.getUser(
    at org.onesync.pdm.uma.user.main.NextGenServicesClien tMain.main(

    Here is a snippet from my Controller which is exposed as web service:
    @RequestMapping(method = RequestMethod.GET, value = "/products/{product_id}", produces="application/json")
    public @ResponseBody
    NextGenItem fetchItem(@PathVariable("product_id") String productId,
    @RequestParam(value = "productIdType", required = true) String productIdType,
    @RequestParam(value = "ipIdType", required = true) String ipIdType,
    @RequestParam(value = "userID", required = true) String userId,
    @RequestParam(value = "operation", required = false) String operation) {

    my dispatcher-servlet.xml is attached below.