java - ArrayList issue in HTTP Servlet -


I am using the Floodlight REST API to monitor the virtual network built in Minnet. My goal is to use the ApacheTomac Web server and HTTP Circlet to switch all the switches, hosts and array of statistics to a web browser. The application successfully displays all the switches and hosts, but fails when I switch Adding Statistics.

When I am mapping the JSON string to the Java object, the server returns an error in this line:

  ArrayList & lt; Switch & gt; Queue = mapper Reed Value (Cusjunction, new typewriter & lt; ArrayList & lt; switch & gt; & gt; () {});   

Error:

  HTTP status 500 - Example of java.util.arraylist start_object can not deserialize outside token  < / pre> 

I have this test done without the queue part (only with the host and device) and everything works fine, but when I am adding ArrayList to the queue, then it is mentioned above Gives the error

How can I resolve this issue? My code is shown in advance thanks in advance

  package core; Import java.io.IOException; Import java.io.StringWriter; Import java.util.ArrayList; Import javax.servlet.ServletException; Import javax.servlet.annotation.WebServlet; Import javax.servlet.http.httpServlet; Import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import org.codehaus.jackson.map.ObjectMapper; Import org.codehaus.jackson.type.TypeReference; Import org.restlet.data.MediaType; Import org.restlet.resource.ClientResource; Import org.restlet.resource.ResourceException; Import pojos.Device; Import pojos.Switch; @WebServlet ("/ PrintInfo") Public Square PrintInfo HttpServlet Extended {Private Static Final Long Serial VERSIONUID = 1L; Public PrintInfo () {super (); } Gate of Secure Zero (HTTPPRVRET Request Request, HTTPPreserve Response Response) Servlet Upption, IOE Expansion {// Creating Client Resources Associate Object // List on changes in network, sources of resources for client resources resources, new customers Resource ("http://127.0.0.1:8080/wm/core/controller/switch/json"); Stringwriters sWriterSwitches = new stringwriter (); // List all the devices (hosts) in the network. ClientResource cResourceDevices = New Client Resource ("http://127.0.0.1:8080/wm/device/"); Stringwriters sWriterDevices = new stringwriter (); // List of switch data in network client resource switch = new client resource ("http://127.0.0.1:8080/wm/core/switch/all/queue/json"); StringWriter sWriterQueues = new stringwriter (); Get JSON data about // switches; Data is inserted into a string author {// Receiving data from Floodlight as a JSON string cResourceSwitches.get (MediaType.APPLICATION_JSON). Write (sWriterSwitches); cResourceDevices.get (MediaType.APPLICATION_JSON) .write (sWriterDevices); cResourceQueues.get (MediaType.APPLICATION_JSON) .write (sWriterQueues); } Catch (Resource Execution E) {request.setAttribute ("Error", "Connection with Floodlight Fails!"); request.getRequestDispatcher ("WEB-INF / connectionError.jsp"). Forwarded (request, response); Return; } // string string from the author to the string object inserted string switches = sWriterSwitches.toString (); String tooljson = sWriterDevices.toString (); String queue jason = sWriterQueues.toString (); // Madonna JSON Data for Java Objects / ObjectMapper JSON - Java ObjectMapper converts between Mapper = new ObjectMapper (); ArrayList & LT; Switch & gt; Switches = mapper Read value (switches, new typewriter & lt; altist & lt; switch & gt; & gt; () {}); ArrayList & LT; Device & gt; Devices = mapper.readValue (devicesJson, new type reference   

}

The switch class can not be used in "ArrayList" for the Hull switch stats. A new class is to be applied, which will be

  http://127.0.0.1:8080/wm/core/switch/all/queue/json   

URI

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -