InvalidClassException question

Discussion in 'Java' started by Aidan, Jun 4, 2004.

  1. Aidan

    Aidan Guest

    According to the docs, this is exception is thrown:

    "when the Serialization runtime detects one of the following problems
    with a Class.

    * The serial version of the class does not match that of the class
    descriptor read from the stream
    * The class contains unknown datatypes
    * The class does not have an accessible no-arg constructor "


    Can someone explain to me what "The class contains unknown datatypes" means?

    I'm getting this exception, and can't figure out why. Both sides (local
    and remote) use the same class, in the same jar, and run in the same JVM
    (which rules out the 1st reason). The class does have a public no-arg
    constructor (which rules out the 3rd reason), and I've tried encoding
    the serialVersionUID directly in the class just to make sure.



    Aidan
    Aidan, Jun 4, 2004
    #1
    1. Advertising

  2. Aidan wrote:
    > According to the docs, this is exception is thrown:
    >
    > "when the Serialization runtime detects one of the following problems
    > with a Class.
    >
    > * The serial version of the class does not match that of the class
    > descriptor read from the stream
    > * The class contains unknown datatypes
    > * The class does not have an accessible no-arg constructor "
    >
    >
    > Can someone explain to me what "The class contains unknown datatypes"
    > means?
    >
    > I'm getting this exception, and can't figure out why. Both sides (local
    > and remote) use the same class, in the same jar, and run in the same JVM
    > (which rules out the 1st reason). The class does have a public no-arg
    > constructor (which rules out the 3rd reason), and I've tried encoding
    > the serialVersionUID directly in the class just to make sure.
    >
    >
    >
    > Aidan


    Problem two means that if any of a classes' members are non-primitive,
    non-serializable objects, then you can't serialize an instance of that
    class.

    Derek
    Derek Chen-Becker, Jun 4, 2004
    #2
    1. Advertising

  3. Aidan

    Aidan Guest

    Derek Chen-Becker wrote:

    > Aidan wrote:
    >
    >> According to the docs, this is exception is thrown:
    >>
    >> "when the Serialization runtime detects one of the following problems
    >> with a Class.
    >>
    >> * The serial version of the class does not match that of the class
    >> descriptor read from the stream
    >> * The class contains unknown datatypes
    >> * The class does not have an accessible no-arg constructor "
    >>
    >>
    >> Can someone explain to me what "The class contains unknown datatypes"
    >> means?
    >>
    >> I'm getting this exception, and can't figure out why. Both sides
    >> (local and remote) use the same class, in the same jar, and run in the
    >> same JVM (which rules out the 1st reason). The class does have a
    >> public no-arg constructor (which rules out the 3rd reason), and I've
    >> tried encoding the serialVersionUID directly in the class just to make
    >> sure.
    >>
    >>
    >>
    >> Aidan

    >
    >
    > Problem two means that if any of a classes' members are non-primitive,
    > non-serializable objects, then you can't serialize an instance of that
    > class.
    >
    > Derek


    Thanks Derek - it actually turned out to be an instance of the 1st
    problem, since some code had been changed to serialize object instances
    to a file. doh!
    Aidan, Jun 4, 2004
    #3
  4. Aidan

    Roedy Green Guest

    Roedy Green, Jun 4, 2004
    #4
  5. Aidan

    Roedy Green Guest

    On Fri, 04 Jun 2004 14:16:39 GMT, Aidan <> wrote or
    quoted :

    >
    >I'm getting this exception, and can't figure out why. Both sides (local
    >and remote) use the same class, in the same jar, and run in the same JVM
    >(which rules out the 1st reason). The class does have a public no-arg
    >constructor (which rules out the 3rd reason), and I've tried encoding
    >the serialVersionUID directly in the class just to make sure.


    Are you getting the problem on write or read?

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 4, 2004
    #5
  6. Aidan

    Roedy Green Guest

    On Fri, 04 Jun 2004 14:16:39 GMT, Aidan <> wrote or
    quoted :

    >I'm getting this exception, and can't figure out why. Both sides (local
    >and remote) use the same class, in the same jar, and run in the same JVM
    >(which rules out the 1st reason). The class does have a public no-arg
    >constructor (which rules out the 3rd reason), and I've tried encoding
    >the serialVersionUID directly in the class just to make sure.


    have you freshly written these objects with your latest class
    definition? Have you utterly proved to yourself you are using
    identical code on both ends? You might write an Integer( version ) at
    the head of both streams just to be sure.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 4, 2004
    #6
  7. Aidan

    Aidan Guest

    Roedy Green wrote:


    >
    > have you freshly written these objects with your latest class
    > definition?


    That was exactly the problem Roedy.
    Aidan, Jun 4, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mario Rosario

    Help - java.io.InvalidClassException

    Mario Rosario, Sep 19, 2003, in forum: Java
    Replies:
    6
    Views:
    21,246
    SteveE
    Sep 24, 2003
  2. Dave Rudolf
    Replies:
    3
    Views:
    4,461
    Sudsy
    Dec 20, 2003
  3. Nomak
    Replies:
    11
    Views:
    1,882
    Arnaud Berger
    Apr 18, 2005
  4. Raga

    InvalidClassException!

    Raga, Sep 26, 2006, in forum: Java
    Replies:
    10
    Views:
    4,423
    shweta.naik
    Aug 22, 2007
  5. Replies:
    1
    Views:
    374
    Manish Pandit
    Jun 18, 2007
Loading...

Share This Page