0

I have a JAVA server using MultiThread to communicate with client. Everything of the Server works, except for when a client object is send to Server thread. I have narrowed down the problem to this following lines of code.

The error is as a result of this line in the code: queryClass= ((QueryClass)inStream.readObject()); //Read data here and QueryClass is a serialized class.

.Am getting the error above. QueryClass is another class, which i have it searialized: Here is my code.

public void run(){
   try{
    ObjectOutputStream outStream=new ObjectOutputStream(clientSocket.getOutputStream());
    ObjectInputStream inStream=new ObjectInputStream(clientSocket.getInputStream());

         while(true){
       sleep(1);
       queryClass=  ((QueryClass)inStream.readObject());    //Read data here
       serverNotification.UpdateNotification("Performing .. operation for TaxOfficer");

    }           
}catch(Throwable thrown){
         System.err.println("Exception Caught : "+thrown+" deleting thread");

}
twain249
  • 5,666
  • 1
  • 21
  • 26
Alex Force
  • 44
  • 7
  • Does `QueryClass` implement `Serializable`? – trutheality Apr 07 '12 at 03:40
  • The server application has the QueryClass in its classpath when it runs? And are you sure you obtain at server side a WriteAbortedException during a read operation? – dash1e Apr 07 '12 at 03:59

1 Answers1

1

QueryClass must implement java.io.Serializable. Make sure that its non-primitive, non-String members do as well. Usually you don't have to do any work to implement the interface. A good write-up is here.

sparc_spread
  • 10,643
  • 11
  • 45
  • 59