InvalidClassException!

Discussion in 'Java' started by Raga, Sep 26, 2006.

  1. Raga

    Raga Guest

    Hi,

    When executing a class am getting this exception:

    java.io.InvalidClassException: package1.Queries; local class
    incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    local class serialVersionUID = -3010695744043114199

    Any idea how to solve this? In fact, I didnt even change anything in
    this class before I got this exception.

    Thanks.
    Raga, Sep 26, 2006
    #1
    1. Advertising

  2. The java virtual machine is indicating that it believes there are two
    versions of a class in play at the same time.

    Does the class read saved objects (saved by serialization)?
    Does the class use RMI?

    Opalinski

    http://www.geocities.com/opalpaweb/




    Raga wrote:
    > Hi,
    >
    > When executing a class am getting this exception:
    >
    > java.io.InvalidClassException: package1.Queries; local class
    > incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    > local class serialVersionUID = -3010695744043114199
    >
    > Any idea how to solve this? In fact, I didnt even change anything in
    > this class before I got this exception.
    >
    > Thanks.
    opalinski from opalpaweb, Sep 26, 2006
    #2
    1. Advertising

  3. Raga

    Raga Guest

    O OK. Thanks a lot. But how do I make the JVM understand that there is
    only one version of the class?

    Nope, the class doesn't use RMI nor does it has to do anything with
    serialized objects. It just manipulates some hashtables.

    Thanks.


    opalinski from opalpaweb wrote:
    > The java virtual machine is indicating that it believes there are two
    > versions of a class in play at the same time.
    >
    > Does the class read saved objects (saved by serialization)?
    > Does the class use RMI?
    >
    > Opalinski
    >
    > http://www.geocities.com/opalpaweb/
    >
    >
    >
    >
    > Raga wrote:
    > > Hi,
    > >
    > > When executing a class am getting this exception:
    > >
    > > java.io.InvalidClassException: package1.Queries; local class
    > > incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    > > local class serialVersionUID = -3010695744043114199
    > >
    > > Any idea how to solve this? In fact, I didnt even change anything in
    > > this class before I got this exception.
    > >
    > > Thanks.
    Raga, Sep 26, 2006
    #3
  4. Raga

    Raga Guest

    sorry,...just noticed. The class implements Serializable. Now what can
    I do to solve the problem?

    Thanks.


    Raga wrote:
    > O OK. Thanks a lot. But how do I make the JVM understand that there is
    > only one version of the class?
    >
    > Nope, the class doesn't use RMI nor does it has to do anything with
    > serialized objects. It just manipulates some hashtables.
    >
    > Thanks.
    >
    >
    > opalinski from opalpaweb wrote:
    > > The java virtual machine is indicating that it believes there are two
    > > versions of a class in play at the same time.
    > >
    > > Does the class read saved objects (saved by serialization)?
    > > Does the class use RMI?
    > >
    > > Opalinski
    > >
    > > http://www.geocities.com/opalpaweb/
    > >
    > >
    > >
    > >
    > > Raga wrote:
    > > > Hi,
    > > >
    > > > When executing a class am getting this exception:
    > > >
    > > > java.io.InvalidClassException: package1.Queries; local class
    > > > incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    > > > local class serialVersionUID = -3010695744043114199
    > > >
    > > > Any idea how to solve this? In fact, I didnt even change anything in
    > > > this class before I got this exception.
    > > >
    > > > Thanks.
    Raga, Sep 26, 2006
    #4
  5. Find out where serialized objects are being read in. The objects being
    read in have a different class definition than the one in the JVM.

    I suspect that's the case.

    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, Sep 26, 2006
    #5
  6. opalinski from opalpaweb wrote:
    > Find out where serialized objects are being read in. The objects being
    > read in have a different class definition than the one in the JVM.


    The problem can also be caused by two different compilers.
    The best option is to set the serialVersionUID in the class:

    http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/class.doc6.html#4100

    You just have to remember to change it when you change the
    implementation :)
    Andrea Desole, Sep 26, 2006
    #6
  7. Raga

    Tim Hallwyl Guest

    Raga wrote:
    > When executing a class am getting this exception:
    >
    > java.io.InvalidClassException: package1.Queries; local class
    > incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    > local class serialVersionUID = -3010695744043114199


    Are you serializing the class? You can declare your own serialVersionUID
    to avoid conflicts between recompiled versions. Just add

    private static final long serialVersionUID = 1;

    to your serializable classes. ...and recompile everything.

    --tim
    Tim Hallwyl, Sep 26, 2006
    #7
  8. Raga

    Raga Guest

    Hi,

    Thanks to all of you for your valuable inputs!

    I got it fixed. The exception msg had a serialVersionUID in it. I used
    it as the serialVersionUID of the class by specifying the foll. line in
    the class:

    static final long serialVersionUID = -3010695744043014199L;

    & it worked! :)


    Thanks.


    Tim Hallwyl wrote:
    > Raga wrote:
    > > When executing a class am getting this exception:
    > >
    > > java.io.InvalidClassException: package1.Queries; local class
    > > incompatible: stream classdesc serialVersionUID = 7965341194343831580,
    > > local class serialVersionUID = -3010695744043114199

    >
    > Are you serializing the class? You can declare your own serialVersionUID
    > to avoid conflicts between recompiled versions. Just add
    >
    > private static final long serialVersionUID = 1;
    >
    > to your serializable classes. ...and recompile everything.
    >
    > --tim
    Raga, Sep 27, 2006
    #8
  9. Raga wrote:
    > Hi,
    >
    > Thanks to all of you for your valuable inputs!
    >
    > I got it fixed. The exception msg had a serialVersionUID in it. I used
    > it as the serialVersionUID of the class by specifying the foll. line in
    > the class:
    >
    > static final long serialVersionUID = -3010695744043014199L;
    >
    > & it worked! :)


    Although this is a good solution, maybe

    static final long serialVersionUID = 1L;

    would be better :)
    The meaning of serialVersionUID, by the way, is that you are able to
    identify different versions. You should think of a numbering convention.
    Just using random numbers might give you a problem.
    Andrea Desole, Sep 27, 2006
    #9
  10. Andrea Desole <> writes:

    > The meaning of serialVersionUID, by the way, is that you are able to
    > identify different versions. You should think of a numbering
    > convention. Just using random numbers might give you a problem.


    Well, "identify" as in "get an annoying exception instead of the
    actual data". So adding serialVersionUID becomes a necessary nuisance.

    A useful versioning field would be instance data, and you could test
    on it in redObject() and/or writeObject() and act accordingly (e.g. by
    "upgrading" the data to ra new version before passing it on).
    Tor Iver Wilhelmsen, Sep 27, 2006
    #10
  11. Raga

    shweta.naik

    Joined:
    Aug 22, 2007
    Messages:
    2
    how to solve this

    java.io.InvalidClassException: ch.ecma.csta.binding.UniversalFailure; local class incompatible: stream classdesc serialVersionUID = -3631400319067888592, local class serialVersionUID = -4780071803391717100
    at java.io_ObjectStreamClass.initNonProxy(Unknown Source)
    at java.io_ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io_ObjectInputStream.readClassDesc(Unknown Source)
    at java.io_ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io_ObjectInputStream.readClassDesc(Unknown Source)
    at java.io_ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io_ObjectInputStream.readObject0(Unknown Source)
    at java.io_ObjectInputStream.defaultReadFields(Unknown Source)
    at java.io_ObjectInputStream.readSerialData(Unknown Source)
    at java.io_ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io_ObjectInputStream.readObject0(Unknown Source)
    at java.io_ObjectInputStream.readObject(Unknown Source)
    at com.avaya.mvcs.proxy.XmlGatewayClient.handleRequest(XmlGatewayClient.java:271)
    at com.avaya.mvcs.proxy.Pipeline.handleRequest(Pipeline.java:353)
    at com.avaya.mvcs.proxy.ClientProxy.routeRequest(ClientProxy.java:501)
    at com.avaya.mvap.svcproxy.ServiceProxy.marshallRequest(ServiceProxy.java:277)
    at com.avaya.mvap.svcproxy.DeviceServicesProxy.getDeviceID(DeviceServicesProxy.java:131)
    shweta.naik, Aug 22, 2007
    #11
    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,217
    SteveE
    Sep 24, 2003
  2. Dave Rudolf
    Replies:
    3
    Views:
    4,448
    Sudsy
    Dec 20, 2003
  3. Aidan
    Replies:
    6
    Views:
    1,057
    Aidan
    Jun 4, 2004
  4. Nomak
    Replies:
    11
    Views:
    1,873
    Arnaud Berger
    Apr 18, 2005
  5. Replies:
    1
    Views:
    367
    Manish Pandit
    Jun 18, 2007
Loading...

Share This Page