[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please help: InvalidClassException



Hi,
I'm not an expert but did you provide a serialVersionUID in your
source for this class?
com.sevenval.fit.contract.ozone.OzoneSiteManagerImpl

If you look at samples/simple you will see this in the AutoImpl.java
file.

final static long serialVersionUID = 1L;

Since Ozone uses serialization, the serialVersionUID needs to be the
same between the
stored object and the one used in the runtime which can change after
compilation if it is not specified in the class.

Hope this helps,
Eric :-)

Jörg Prante wrote:
> 
> Hi!
> 
> While using Ozone DB in a client-server environment powering a Tomcat servlet
> engine, I often stop and start the servlet engine together with the Ozone DB
> server. A SiteManagerImpl class accesses some Ozone objects when starting up
> the system. This works fine for the first time, when the database is empty.
> After the first run, the database is filled with objects. These objects
> should be available for reading at the next time. When I subsequently
> shutdown the system, compile, and start again, the Ozone server sometimes
> denies reading the objects from the database - and sometimes not.
> 
> In WizardObjectContainer, the following method sometimes throws an
> InvalidClassException while the system is restarting:
> 
> -------- code snippet from WizardObjectContainer.java ---------
> 
>     public final void readExternal( ObjectInput in ) throws IOException,
> ClassNotFoundException {
>         // System.out.println ("container.readExternal()...");
>         byte streamVersion = in.readByte();
>         target = (OzoneCompatible)in.readObject();
>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>               >>>>>this line throws the exception<<<<<<
> 
>         if (target != null) {
>             target.setContainer( this );
>         }
>         // objID = (ObjectID)in.readObject();
>         objID = new ObjectID( in.readLong() );
>         name = null;
>         if (in.readByte() != 0) {
>             name = in.readUTF();
>         }
>         state = (int)in.readByte();
>     }
> ---------------- end of code snippet -------------
> 
> Here is the stack trace of the exception:
> 
> -------- snip ---------
> [warn] (903) Transaction: objectForName()
>     java.io.InvalidClassException: com.sevenval.fit.contract.ozone.OzoneSi
>             teManagerImpl; Local class not compatible: stream classdesc
> serialVers
>             ionUID=-4269804347343892228 local class
> serialVersionUID=-730019390930
>             258627
>         at java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.jav
>             a:523)
>         at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
>         at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.j
>             ava:936)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
>         at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
>         at org.ozoneDB.core.wizardStore.WizardObjectContainer.readExternal(Wi
>             zardObjectContainer.java:216)
>         at org.ozoneDB.core.wizardStore.Cluster.readExternal(Cluster.java:340
>             )
>         at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1212)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
>         at org.ozoneDB.core.wizardStore.ClusterStore.loadData(ClusterStore.ja
>             va:682)
>         at org.ozoneDB.core.wizardStore.ClusterStore.loadCluster(ClusterStore
>             .java:328)
>         at org.ozoneDB.core.wizardStore.WizardStore.containerForID(WizardStor
>             e.java:362)
>         at org.ozoneDB.core.wizardStore.WizardStore.containerForName(WizardSt
>             ore.java:386)
>         at org.ozoneDB.core.Transaction.objectForName(Transaction.java:575)
>         at org.ozoneDB.core.DbRemote.DbObjForName.perform(DbObjForName.java:3
>             6)
>         at org.ozoneDB.core.Transaction.performCommand(Transaction.java:273)
>         at org.ozoneDB.core.TransactionManager.performCommand(TransactionMana
>             ger.java:366)
>         at org.ozoneDB.core.TransactionManager.completeTransaction(Transactio
>             nManager.java:334)
>         at org.ozoneDB.core.TransactionManager.handleCommand(TransactionManag
>             er.java:249)
>         at org.ozoneDB.core.InvokeServer.handleClientEvent(InvokeServer.java:
>             76)
>         at org.ozoneDB.DxLib.net.DxMultiServerClient.run(DxMultiServerClient.
>             java:43)
>         at java.lang.Thread.run(Thread.java:484)
> -------   snip ----------
> 
> The only workaround I know is to re-initialize the whole database, deleting
> all data. This is surely not desirable at all.
> 
> Please explain to me how I can get out of this situation, or how I can fix
> this. Maybe it's an Ozone bug, or an odd Java feature of de-serializing
> classes. I suppose the serialization class ID mismatch comes from proxy
> communication with the Ozone server, which might expect identical objects,
> but this identity is destroyed between compile/build cycles. I don't
> understand the Ozone implementation completely, so I'm not able to improve
> the readExternal() method in WizardObjectContainer. However, the class ID
> mismatch between different Ozone runs is strange and should not happen.
> 
> The software I'm using:
> 
> - Linux 2.2.16
> - Sun Java JDK 1.3.0
> - OzoneDB 0.6 (same WizardObjectContainer code also present in 1.0.1)
> 
> The Ozone 0.6 source code is included into the build system, and Ozone proxy
> code for SiteManagerImpl is auto-generated by Ant each turn-around
> (SiteManagerImpl_Proxy.java).
> 
> Jörg
> 
> --
> Jörg Prante
> Sevenval AG (HRB 32757) e-business marketing technologies
> D-50667 Köln . Alter Markt 36-42
> Fon +49 221 65 00 70 . Fax +49 221 42 49 891 . Mobile +49 175 466 19 18
> http://www.sevenval.de . joerg@7val.com