Can not deserialize instance of java.lang.String out of START_OBJECT using Spring Rest Template -


i using rest template invoke third party restful api. getting "can not serialize instance of java.lang.string out of start_object" below code:

xml file:  <!-- restful interaction --> <bean id="jsonconverter" class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter">     <property name="supportedmediatypes" value="application/json" /> </bean> <bean id="resttemplate" class="org.springframework.web.client.resttemplate">     <property name="messageconverters">         <list>             <ref bean="jsonconverter" />         </list>     </property> </bean>  **java code:**  response= resttemplate.getforobject(url, string.class); 

the url valid url in resttemplate.getforobject() method. verified putting same url in browser , produces valid json object.

below error getting:

[5/9/13 16:25:56:352 cdt] 00000028 systemerr r org.springframework.http.converter.httpmessagenotreadableexception: not read json: can not deserialize instance of java.lang.string out of start_object token @ [source: sun.net.www.protocol.http.httpurlconnection$httpinputstream@3dd83dd8; line: 1, column: 1]; nested exception org.codehaus.jackson.map.jsonmappingexception: can not deserialize instance of java.lang.string out of start_object token @ [source: sun.net.www.protocol.http.httpurlconnection$httpinputstream@3dd83dd8; line: 1, column: 1]

what doing wrong?

i found solution. problem was using 1 message converter. after removing the

<property name="messageconverters">         <list>             <ref bean="jsonconverter" />         </list>     </property> 

this code bean declaration started working. because resttemplate started using it's own message converters. code looks this:

<!-- restful interaction --> <bean id="resttemplate" class="org.springframework.web.client.resttemplate" /> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -