yafmbl
6 May 2009, 5:29 AM
Hi,
For some debugging purposes, we decided to keep some of our classes in serialized form, in a BLOB field of the DB.
The classes extend BaseModel class. BaseModel class contains a field of type RpcMap, which is not serializable itself. So, the actual JAVA serialization gives an error.
Here is a sample code snippet which produces the same exception:
BaseModel model = new BaseModel( ) ;
model.set( "somefield", "somevalue" ) ;
model.set( "anotherfield", "another value" ) ;
ByteArrayOutputStream baos = new ByteArrayOutputStream( ) ;
ObjectOutput oos = new ObjectOutputStream( baos ) ;
oos.writeObject( model ) ;
byte[ ] data = baos.toByteArray( ) ;
System.err.println( "size:" + data.length ) ;
The exception is:
Exception in thread "main" java.io.NotSerializableException: com.extjs.gxt.ui.client.data.RpcMap
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
What we want to do in short is to be able to run the above code with minimum change.
Thanks in advance...
For some debugging purposes, we decided to keep some of our classes in serialized form, in a BLOB field of the DB.
The classes extend BaseModel class. BaseModel class contains a field of type RpcMap, which is not serializable itself. So, the actual JAVA serialization gives an error.
Here is a sample code snippet which produces the same exception:
BaseModel model = new BaseModel( ) ;
model.set( "somefield", "somevalue" ) ;
model.set( "anotherfield", "another value" ) ;
ByteArrayOutputStream baos = new ByteArrayOutputStream( ) ;
ObjectOutput oos = new ObjectOutputStream( baos ) ;
oos.writeObject( model ) ;
byte[ ] data = baos.toByteArray( ) ;
System.err.println( "size:" + data.length ) ;
The exception is:
Exception in thread "main" java.io.NotSerializableException: com.extjs.gxt.ui.client.data.RpcMap
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
What we want to do in short is to be able to run the above code with minimum change.
Thanks in advance...