java - Response cannot cast to JSON -
inside application triggering below code
resttemplate client=new resttemplate(); if(ipaddress.length>0) { (int = 0; < ipaddress.length; i++) { system.out.println(baseurl+"/grid/api/proxy?id="+ipaddress[i]); responseentity<object> object= client.getforentity(baseurl+"/grid/api/proxy?id="+ipaddress[i], object.class); system.out.println(object); } }
the result object return shown below:
<200 ok,{success=true, msg=proxy found !, id=http://192.168.3.37:5555, request={class=org.openqa.grid.common.registrationrequest, id=null, name=null, description=null, configuration={port=5555, servlets=[], host=192.168.3.37, dwebdriver.ie.driver=c:\anoop\iedriver\iedriverserver.exe=, cleanupcycle=5000, dwebdriver.chrome.driver=c:\anoop\chromedriver\chromedriver.exe=, browsertimeout=0, hubhost=localhost, registercycle=5000, capabilitymatcher=org.openqa.grid.internal.utils.defaultcapabilitymatcher, newsessionwaittimeout=-1, hub=http://localhost:4444/grid/register, url=http://192.168.3.37:5555, remotehost=http://192.168.3.37:5555, register=true, throwoncapabilitynotpresent=true, nodepolling=5000, proxy=org.openqa.grid.selenium.proxy.defaultremoteproxy, browser=browsername=firefox, maxsession=5, role=node, jettymaxthreads=-1, hubport=4444, timeout=300000}, capabilities=[{seleniumprotocol=webdriver, platform=win8_1, browsername=firefox}, {seleniumprotocol=webdriver, platform=win8_1, browsername=chrome}, {seleniumprotocol=webdriver, platform=win8_1, browsername=internet explorer}]}}, {content-type=[application/json;charset=utf-8], content-length=[1185], server=[jetty(7.x.y-snapshot)]}>
if use jsonobject
here instead of object
in response entity method get{}
how possible convert object
jsonobject
?
note: application not web application.
the following code can use in application-context.xml while configuring resttemplate.
<beans:bean id="resttemplate" class="org.springframework.web.client.resttemplate"> <constructor-arg ref="httpclientfactory" /> <property name="messageconverters"> <list> <beans:bean class="org.springframework.http.converter.bytearrayhttpmessageconverter" /> <beans:bean class="org.springframework.http.converter.formhttpmessageconverter" /> <beans:bean class="org.springframework.http.converter.stringhttpmessageconverter" /> <beans:bean class="org.springframework.http.converter.xml.sourcehttpmessageconverter" /> <beans:bean class="org.springframework.http.converter.xml.marshallinghttpmessageconverter"> <constructor-arg> <beans:bean class="org.springframework.oxm.xstream.xstreammarshaller" /> </constructor-arg> </beans:bean> <ref bean="jsonconverter" /> </list> </property> </beans:bean> <beans:bean id="jsonconverter" class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter"> <property name="supportedmediatypes" value="application/json" /> </beans:bean> <beans:bean id="annotationmethodhandleradapter" class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <property name="messageconverters"> <list> <ref bean="jsonconverter" /> </list> </property> </beans:bean>
hope stuff helps you.let me known if doubt.
Comments
Post a Comment