9 Replies Latest reply on Oct 27, 2010 1:08 AM by EJP

    Thread unserialized exception: NotSerializableException: java.lang.Thread

    808188
      hello experts,
      i have this exception coming; seems to be coming from some thread but i removed all the threads from my code, i thought its because of some object which is still unserialized, i am not sure whether this is because of one unserialized object or its because of more reasons, please have a look:



      Exception in client main: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
           java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
      java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
           java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
           at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
           at BallServerImpl_Stub.getAllBallProxies(Unknown Source)
           at CopyOfManyMovingBalls.<init>(CopyOfManyMovingBalls.java:80)
           at CopyOfManyMovingBalls$2.run(CopyOfManyMovingBalls.java:294)
           at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
           at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
           at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
           at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
           at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
      Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Thread
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
           at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
           at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
           at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
           at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
           at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
           at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
           at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
           ... 11 more

      this is coming  when i m accessing this method:

      class BallServerImpl extends UnicastRemoteObject
      implements BallServer
      {

      ....

      /**
      * @return an enumeration of all Balls as proxy objects
      **/
      public Ball[] getAllBallProxies() throws java.rmi.RemoteException
      {
           Ball[] locations1 = new Ball[hash.size()];
      java.util.Enumeration iter = hash.elements();
      int idx = 0;
      while (iter.hasMoreElements())
      {
           BallImpl impl = (BallImpl)iter.nextElement();
      locations1[idx++] = new BallProxy(impl);
      }
      return locations1;

      }

      why this function is running fine when i m calling this from client unlike getAllBallProxies() nevertheless both are returning the same thing:

      /**
      * @return an enumeration of all Balls as remote references
      **/
      public Ball[] getAllBalls()
      {
           Ball[] locations = new Ball[hash.size()];
      java.util.Enumeration iter = hash.elements();
      int idx = 0;
      while (iter.hasMoreElements())
      {
      locations[idx++] = (Ball)iter.nextElement();
      }
      return locations;
      }



      the proxy Class:

      /**
      * The Proxybouncing ball.
      */
      public class BallProxy implements Serializable,Ball {
      ....
      }

      /**
      * The Real bouncing ball.
      */
      public class BallImpl extends UnicastRemoteObject implements IBallRemote,Serializable
      {
      ...
      }

      *load of thanks as this is "SHOW STOPPER",
      jibbylala*

      Edited by: 805185 on Oct 25, 2010 8:33 PM

      Edited by: 805185 on Oct 25, 2010 8:39 PM

      Edited by: 805185 on Oct 25, 2010 9:21 PM

      Edited by: 805185 on Oct 25, 2010 9:25 PM

      Edited by: 805185 on Oct 25, 2010 9:27 PM

      Edited by: 805185 on Oct 25, 2010 9:46 PM