Results 1 to 4 of 4
  1. #1
    nouvaki is offline Member
    Join Date
    Dec 2009
    Posts
    3
    Rep Power
    0

    Default Serializable problem in writeObject method

    The following command throws me a NotSerializableException.

    myOutputStreamObject.writeObject(_peer);

    Why??
    The _peer is an instance of a Peer class which implements serializable interface and has a static final long serialVersionUID = 40L.
    Inside it i have int and String variables and two Vectors:
    1) Vector<InetAddress> ipAddresses
    2) Vector<Advertisement> adds (Advetrisment is a class which also implements Serializable and has two int variables)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by nouvaki View Post
    The following command throws me a NotSerializableException.

    myOutputStreamObject.writeObject(_peer);

    Why??
    The _peer is an instance of a Peer class which implements serializable interface and has a static final long serialVersionUID = 40L.
    Inside it i have int and String variables and two Vectors:
    1) Vector<InetAddress> ipAddresses
    2) Vector<Advertisement> adds (Advetrisment is a class which also implements Serializable and has two int variables)
    The Serialization mechanism doesn't lie: it found an object somewhere that isn't Serializable; check you Advertisement and Peer classes for such a member. Also use the 'serialver' tool for the calculation of the serialVersionUID values.

    kind regards,

    Jos

  3. #3
    nouvaki is offline Member
    Join Date
    Dec 2009
    Posts
    3
    Rep Power
    0

    Default

    the serialver opens me a window asking me the full class name. I put the class name but it doesn't find it.

    My file's path is
    C:\eclipse\workspace\Peer2Peer\src\Advertisement.j ava.

    how can i do that in command line?
    serialver.exe -classpath C:\eclipse\workspace\Peer2Peer\src Advertisement???

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by nouvaki View Post
    the serialver opens me a window asking me the full class name. I put the class name but it doesn't find it.

    My file's path is
    C:\eclipse\workspace\Peer2Peer\src\Advertisement.j ava.

    how can i do that in command line?
    serialver.exe -classpath C:\eclipse\workspace\Peer2Peer\src Advertisement???
    Just like the other tools it needs a classpath and a fully qualified class name, e.g. your.package.YourClass.

    kind regards,

    Jos

Similar Threads

  1. Casting to an List<Serializable>
    By Whatty in forum Advanced Java
    Replies: 5
    Last Post: 10-15-2009, 07:47 PM
  2. Replies: 0
    Last Post: 12-31-2008, 02:20 PM
  3. source for OutputStream.writeObject()
    By xcallmejudasx in forum New To Java
    Replies: 5
    Last Post: 12-12-2008, 09:53 PM
  4. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  5. Implementing Serializable interface
    By javaplus in forum Advanced Java
    Replies: 4
    Last Post: 12-18-2007, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •