commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanzo Luca <Luca.Dava...@INSIEL.IT>
Subject [commons-lang] SerializationException in SerializationUtils
Date Fri, 16 Jan 2004 15:14:46 GMT
Hi all,
I dont understand  the  reason of this exception.
In my test I try to serialize an Hashtable to a byte[], create a string with
that byte[] and then deserialize (below the source code and the exception)
Note  that if my Hashtable contains only strings the exception does not
occur.
Using commons-lang 2.0


-----Source code------

public void testSerialize() {
	java.util.Hashtable h1= new java.util.Hashtable();
	h1.put("c1", "t1");
	h1.put("c2","t2");

	Date d= new Date();
	h1.put("d1",d);
	byte[] bytes= SerializationUtils.serialize(h1);
	String str= new String(bytes);
	System.out.println("Striaaanga"+ str1);
// SerializationException on next line
// note thatNO EXCEPTION if uI deserialize from bytes 

	java.util.Hashtable h2=
(java.util.Hashtable)SerializationUtils.deserialize(str.getBytes());
assertEquals(h1, h2);
}

----SerializationException ----
org.apache.commons.lang.SerializationException:
java.io.InvalidClassException: java.util.Date; Local class not compatible:
stream classdesc serialVersionUID=7523895402267505689 local class
serialVersionUID=7523967970034938905
	at
org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.ja
va:204)
	at
org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.ja
va:229)
	at
CorrelatePersonServiceTest.testSerialize(CorrelatePersonServiceTest.java:130
)



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message