This is a snippet of my client server problem the follow is on the server program.
Product Class
public class Products{ String pCode, pName, pShDesc,pLoDesc,supplier; int itemsInStock,low; double salePrice,unitPrice; public Products(){ this.pCode=""; this.pName=""; this.pShDesc=""; this.pLoDesc=""; this.itemsInStock=0; this.low=50; this.salePrice=0.0; this.unitPrice=0.0; this.supplier=""; }
Client Class has objects along with others that are not used witin this problem all are initialized properly and been tested over the server
protected Socket socket = null; protected ObjectInputStream in = null; protected ObjectOutputStream out = null;
Now the client initiates a call to server via
List<Products> sList = (LinkedList) client.in.readObject();
The server now responds to the call by doing:
out.writeObject(selectProduct());
This calls the select Product function:
public List<Products> selectProduct() { Products obj = null; List<Products> sList=new LinkedList<Products>(); try { stat = con.createStatement(); String query = "SELECT * FROM Product"; res = stat.executeQuery(query); while(res.next()) { obj = new Products(); obj.setpCode(res.getString(1)); obj.setpName(res.getString(2)); obj.setpShDesc(res.getString(3)); obj.setpLoDesc(res.getString(4)); obj.setItemsInStock(res.getInt(5)); obj.setLow(res.getInt(6)); obj.setSalePrice(res.getDouble(7)); obj.setUnitPrice(res.getDouble(8)); obj.setSupplier(res.getString(9)); sList.add(obj); } } catch(SQLException ex) { System.out.println("Error occured\n" + ex.getMessage()) ; } return sList; }
The problem occurs when the server is writing to the client via
out.writeObject(selectProduct());
Where the out.writeObject throws the error on the client side
IOException occurred
writing aborted; java.io.NotSerializableException: object.Products
server side error
IO Exception
object.Products
[Ljava.lang.StackTraceElement;@8965fb
Ive been reading and looking around for hours... any idea how i can fix this? Tried to be as detailed as i could.