0

I am getting no suitable HttpMessageConverter found error only on AWS, where as it is working perfect on Cloud Foundry and I'm getting the response.

Do I need to make any special configuration for RestTemplate in order to work on AWS?

Configuration class

@Configuration
public class RestTemplateConfiguration {

    @Bean
    RestTemplate restTemplate() {

        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setOutputStreaming(false);

        RestTemplate restTemplate =  new RestTemplate(requestFactory);
        restTemplate.setErrorHandler(new RestResponseErrorHandler());

        return restTemplate;
    }
}

Client class

@Component
public class RestClient {

    private final RestTemplate restTemplate;

    @Autowired
    public RestClient(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;        
    }


    public ResponseObj getData() {
            return restTemplate.postForObject("http://somehost:port/data", requestObj, ResponseObj.class);
    }
}

both requestObj and ResponseObj classes are POJO classes.

Error:

{
  "timestamp": 1471491645132,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "org.springframework.web.client.RestClientException",
  "message": "Could not extract response: no suitable HttpMessageConverter found for response type [class com.bosch.lui.connectservice.model.poi.response.PoiResponse] and content type [text/html;charset=iso-8859-1]",
  "path": "/lui/v1/omni/pois/search"
}
Pratap A.K
  • 4,337
  • 11
  • 42
  • 79
  • see http://stackoverflow.com/questions/21854369/no-suitable-httpmessageconverter-found-for-response-type – Magnus Aug 18 '16 at 05:17
  • @Magnus I'm curious to know why it's failing only on AWS where as it's working fine on CloudFoundry? – Pratap A.K Aug 18 '16 at 05:44
  • 2
    The api you are calling is returning different content type in either environment, why this is happening is impossible to answer with the information you have provided, but it is unlikely to have anything to do with what platform it is running on. – Magnus Aug 18 '16 at 05:49
  • @Magnus thanks for clarifying. Indeed server is returning html error page with error message "Your requested host "xyz.com" could not be resolved by DNS." – Pratap A.K Aug 18 '16 at 05:51
  • 1
    A good way to troubleshoot issues like this is to set the log level of the `org.apache.http.wire` package to DEBUG so you can see the request and response payload to determine what Spring is trying to convert. – Shawn Clark Aug 18 '16 at 06:20
  • @ShawnClark Thanks, i'll do the same – Pratap A.K Aug 18 '16 at 07:27

0 Answers0