Q:

Getting NotSerializableException when trying to write object

Trying to serialize and send Lot object to socket. Getting error:
java.io.NotSerializableException: com.server.ClientServiceThread

Why?
public class ClientServiceThread extends Thread  {... // form here called sendObj ...}

public class FlattenLot {
public void sendObj(){
        try {
            out = new ObjectOutputStream(oStream);
            out.writeObject(lot); // error
            out.flush();
            out.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

Lot class:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import java.util.Date;
import java.util.Calendar;

public class Lot implements Serializable{
private static final long serialVersionUID = 1L;
    public ArrayList<ClientServiceThread> clientBidsLog = new ArrayList<ClientServiceThread>();
    public ArrayList<Integer> bidLog = new ArrayList<Integer>();

    private List<Integer> bids = new ArrayList<Integer>();
    private List<ClientServiceThread> clients = new ArrayList<ClientServiceThread>();

    private  String NAME;
    private  int INITIAL_PRICE;

    private int MAX_BID = 0;
    public volatile boolean notAvailable = false;
Lot(String name, int initPrice){
        NAME = name;
        INITIAL_PRICE = initPrice;
    }
public synchronized String getName(){return NAME;}
public synchronized int getInitPrice(){return INITIAL_PRICE;}
public synchronized void subscribe(ClientServiceThread t){
        clients.add(t);
      }
public synchronized void unsubscribe(ClientServiceThread t){
        clients.remove(t);
      }
public  synchronized boolean makeBid(ClientServiceThread t,int i){
          if(i > INITIAL_PRICE && i > MAX_BID){
                clientBidsLog.add(t);
                bidLog.add(i);
                bids.add(i);
                MAX_BID = i;
                t.LAST_BID = i;
                notifyAllSubscribers("New bid: "+this.getMaxBid()+" made by "+this.clientBidsLog.get(this.clientBidsLog.size()-1).CLIENT_NAME);
                return true;
          }else{
                return false;
          }

          }
public synchronized void notifyAllSubscribers(String msg){
        for (ClientServiceThread client : clients){
              client.lotUpdated(this, msg);
            }
    }
public synchronized int getMaxBid(){return MAX_BID;}

    private Date time;

    public Lot() {
        time = Calendar.getInstance().getTime();
    }

    public Date getTime() {
        return time;
    }
    }

A:

The error is caused by trying to serialize a ClientServiceThread, which is not serializable. Somehow one of those is part of a Lot. If Lot is not declared with a ClientServiceThread field (or with a field that contains a ClientServiceThread), then another possibility is that Lot is a non-static inner class of a class that does have such a field. The outer class instance would then be a (hidden) member of Lot.
The solution is to either make ClientServiceThread serializable (not likely, from its name) or else eliminate it from the serialization by marking the relevant field(s) transient (or removing them from the Lot class).

A:

Lot contains
public ArrayList<ClientServiceThread> clientBidsLog 
private List<ClientServiceThread> clients

If you wish this field to be serialized mark the ClientServiceThread serializable too
if you don't want it to be serialized just mark it transient like
public transient ArrayList<ClientServiceThread> clientBidsLog 
private transient List<ClientServiceThread> clients

