lundi 2 mars 2015

org.springframework.web.client.RestClientException: Could not extract response:

I'm creating a restful API which will consume json from server. But i'm getting the foll exception :


org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [[Lexamples.dto.DummyDTO;] and content type [text/json;charset=utf-8] at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:84) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:454) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:207) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)


Code snippet :



List<HttpMessageConverter<?>> msgConverters = restTemplate.getMessageConverters();
msgConverters.add(new MappingJacksonHttpMessageConverter());
restTemplate.setMessageConverters(msgConverters);
DummyDTO[] dummy= restTemplate.getForObject(URI, DummyDTO[].class);


Please tell me where am i going wrong


Aucun commentaire:

Enregistrer un commentaire