Announcement Announcement Module
Collapse
No announcement yet.
RestClientException:Cannot extract response: no Content-Type found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 or.java:84)
    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(RestTemplate.java:454)
    at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:409)
    at org.springframework.web.client.RestTemplate.exchan ge(RestTemplate.java:385)
    at org.onesync.pdm.uma.user.main.NextGenServicesClien tMain.getUser(NextGenServicesClientMain.java:58)
    at org.onesync.pdm.uma.user.main.NextGenServicesClien tMain.main(NextGenServicesClientMain.java:46)

    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.
Working...
X