TCP android Class Cast Exception : Hi I am trying to send a custom list of objects from Client to server. I am getting a class cast exception. I am using Android studio emulator for my client and running my Server on Eclipse. I even wrote a test code to check to see if it works in eclipse and it does. But for some reason does not work on android. I am new to android

    import java.io.Serializable;
    import java.util.Arrays;
    
    
    public class Document implements Serializable {
    private static final long serialVersionUID = 1L;
    String id;
    String name;
    String address;
    String[] category;
    float lattitude;
    float longitude;
    String city;
    double stars;
    double overallRating;
    // String attributes[];
    Review[] reviews;
    
    public Document(String id, String name, String address, String[] category, float longitude, float lattitude,
    		String city, double stars, double overallRating, Review[] review) {
    	super();
    	this.id = id;
    	this.name = name;
    	this.address = address;
    	this.category = category;
    	this.longitude = longitude;
    	this.lattitude = lattitude;
    	this.city = city;
    	this.stars = stars;
    	this.overallRating = overallRating;
    	this.reviews = review;
    }
    
    @Override
    public String toString() {
    	return "Document [id=" + id + ", name=" + name + ", address=" + address + ", category="
    			+ Arrays.toString(category) + ", lattitude=" + lattitude + ", longitude=" + longitude + ", city=" + city
    			+ ", stars=" + stars + "]";
    }
    
    }




    import java.io.Serializable;
    
    public class Review implements Serializable {
    
    	private static final long serialVersionUID = -1595783420656910821L;
    	double stars;
    	String review;
    
    	public Review(double stars, String review) {
    		this.stars = stars;
    		this.review = review;
    	}
    
    }






//Part of the server

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.ObjectOutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.net.Socket;
    import java.util.List;
    
    public class CommunicatewithMobileDevice implements Runnable {
    Socket conn;
    private InvertedIndexA invertedIndex;
    private BufferedReader br;
    private ObjectOutputStream oos;
    private PrintWriter pw;
    
    public CommunicatewithMobileDevice(Socket sock, InvertedIndexA invertedIndex) {
    	conn = sock;
    	this.invertedIndex = invertedIndex;
    	try {
    		br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    		pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()), true);
    	} catch (IOException e) {
    		e.printStackTrace();
    	}
    }
    
    public void run() {
    
    	try {
    		
    		String ip = br.readLine();
    
    		String input[] = br.readLine().split(" ");
    		System.out.println(ip + " " + input[0] + " " + input[1]);
    		List<Document> docs = invertedIndex.search(ip, Float.valueOf(input[0]), Float.valueOf(input[1]));
    		System.out.println(docs.size());
    		oos = new ObjectOutputStream(this.conn.getOutputStream());
    		oos.writeObject(docs);
    		
    	
    		oos.flush();
    	} catch (IOException e) {
    		e.printStackTrace();
    	}
    }
    
    }

//A singleton or a server

    import java.io.IOException;
    import java.net.ServerSocket;
    import java.net.Socket;
    
    
    public class Singleton implements Runnable {
    	private ServerSocket conn;
    	private static InvertedIndexA invertedIndex = new InvertedIndexA(Helper.loadCategories());
    	private boolean isStopped = false;
    
    	private Singleton() {
    	}
    
    	public static InvertedIndexA getInstance() {
    		return invertedIndex;
    	}
    
    	public static void main(String args[]) {
    		new Thread(new Singleton()).start();
    	}
    
    	public void acceptsClients() {
    		try {
    			synchronized (this) {
    				conn = new ServerSocket(1503);
    			}
    			while (!isStopped()) {
    				Socket sock = conn.accept();
    				//System.out.println("Conn accepted");
    				new Thread(new CommunicatewithMobileDevice(sock, invertedIndex)).start();
    			}
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    
    	}
    
    	private synchronized boolean isStopped() {
    		return this.isStopped;
    	}
    
    	public synchronized void stop() {
    		this.isStopped = true;
    		try {
    			this.conn.close();
    		} catch (IOException e) {
    			throw new RuntimeException("Error closing server", e);
    		}
    	}
    
    	@Override
    	public void run() {
    		acceptsClients();
    	}
    }

//The android client or a part of it

    import android.Manifest;
    import android.content.pm.PackageManager;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.design.widget.Snackbar;
    import android.support.v4.app.ActivityCompat;
    import android.support.v7.app.AppCompatActivity;
    import android.support.v7.widget.Toolbar;
    import android.util.Log;
    import android.view.View;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.ObjectInputStream;
    import java.io.PrintWriter;
    import java.net.Socket;
    import java.util.ArrayList;
    import java.util.List;
    
    import android.widget.ListView;
    import android.widget.TextView;
    import android.content.Context;
    
    public class ListOfResults extends AppCompatActivity {
    
        CommunicateWithServer comm;
        GPSTracker gps;
        String message = "";
        List<Document> docs;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_list_of_results);
            comm = new CommunicateWithServer();
            Bundle bundle = getIntent().getExtras();
            message = bundle.getString("message");
            //new Communicate().execute();
            new Thread(runnable).start();
        }
    
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                try {
                    Socket sock = new Socket("129.21.114.74", 1503);
                    PrintWriter pw = new PrintWriter(sock.getOutputStream(), true);
                    pw.println(message);
                    double latitude = 0;
                    double longitude = 0;
                    pw.println(new String(Double.valueOf(latitude) + " " + Double.valueOf(longitude)));
                    ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
                    docs = (List<Document>) ois.readObject();
                    BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                    //Log.e("print the val",br.readLine());
                    //System.out.println(docs.size());
                    Log.e("size", Integer.toString(docs.size()));
    
    
                } catch (IOException | ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    System.out.println("yeassass");
                }
            }
        };
    
        public void populate(String result) {
            Log.e("here", "here");
            DocumentAdapter documentAdapter = new DocumentAdapter(this, docs);
            ListView listView = (ListView) findViewById(R.id.listView1);
            listView.setAdapter(documentAdapter);
        }
    }

//This was a test program i wrote to test the server code. Works fine here
   

     import java.io.IOException;
        import java.io.ObjectInputStream;
        import java.io.PrintWriter;
        import java.net.Socket;
        import java.util.List;
        
        public class Test implements Runnable {
        
        	public Test() {
        		// TODO Auto-generated constructor stub
        	}
        
        	public static void main(String args[]) {
        		Test test = new Test();
        		new Thread(test).start();
        	}
        
        	public void run() {
        		testOp();
        	}
        
        	private void testOp() {
        		try {
        			Socket sock = new Socket("localhost", 1503);
        			PrintWriter pw = new PrintWriter(sock.getOutputStream(), true);
        			String location = Helper.getLocation();
        			location = location.substring(location.lastIndexOf(") ") + 2);
        			String split[] = location.split(",");
        			pw.println("Chinese");
        			pw.println(new String(split[0] + " " + split[1]));
        			ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
        			List<Document> docs = (List<Document>) ois.readObject();
        			System.out.println(docs);
        		} catch (IOException | ClassNotFoundException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        	}
        }










