-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: deserialization problem with MySQL?
PostPosted: Wed Nov 19, 2003 6:13 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
Hi!
I've created a class and a mapping for it.
I developed my application using hibernate with the hsql-database, which worked fine for me.
However: I tryed to switch to a Mysql-DB, so I changes the hibernate.properties to match my MySQL-Settings.

My application can write to tha new MYSQL-Database and serialize all Objects without a problem but when it comes to loading these Objects, hibernate gives me an Exception which says: Unable to deserialize a serializable property...

It's exactly the same source code, that workes with hsql and it still works when switching back... The serialisation works fine with Mysql..


Can somebody help me?

I've tryed using the 2.0.2 and the 2.1 Beta...


Thanks,
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 1:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You have to give more precisions

_________________
Emmanuel


Top
 Profile  
 
 Post subject: MySQL-Probelm with deserialization
PostPosted: Wed Nov 19, 2003 4:24 pm 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
No problem. I got the following Mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <!-- de.abelssoft.GeneralCachingEngine.CachingElement root -->
   <class name="de.abelssoft.GeneralCachingEngine.CachingElement" table="CACHINGELEMENT">
      <id name="ID" type="int" column="ID">
         <generator class="hilo"/>
      </id>
      <property name="upToDateTill" column="UPTODATETILL" type="calendar"/>
      <property name="lastCached" column="LASTCACHED" type="calendar"/>
      <property name="object" column="OBJECT" type="serializable"/>
      <property name="autokill" column="AUTOKILL" type="boolean"/>
      <property name="uniquekey" column="UNIQUEKEY" type="string"/>
      <property name="timeToLive" column="TIMETOLIVE" type="int"/>
   </class>
</hibernate-mapping>



and it works fine with hsql. When using MySQL, I can serialize but the deserialization gives me an exception. This is from my tomcat logfile:

Quote:
2003-11-19 21:18:56 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2165)
at java.io.ObjectInputStream$BlockDataInputStream.readUnsignedShort(ObjectInputStream.java:2643)
at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2701)
[...]
(ObjectInputStream.java:1271)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:165)
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:191)
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:72)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:60)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:51)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:494)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:448)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:417)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:356)
at net.sf.hibernate.loader.Loader.doResultSet(Loader.java:190)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:113)
at net.sf.hibernate.loader.Loader.find(Loader.java:736)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:101)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3409)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:137)
at
[... my classes now...]
at java.lang.Thread.run(Thread.java:534)

rethrown as org.apache.commons.lang.SerializationException
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:170)
at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:191)
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:72)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:60)
[...]


at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:165)
... 50 more
rethrown as net.sf.hibernate.type.SerializationException: Could not deserialize a serializable property:
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:75)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:60)




Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 3:36 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Sorry no good tip ;-(
Check the DB type of your OBJECT column.

HiLo cannot be used in JTA your with user suppied connection, but it's not related.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: MYSQL-PRoblem with deserialization
PostPosted: Thu Nov 20, 2003 5:37 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
Quote:
Check the DB type of your OBJECT column.


I've done this.
It's
OBJECT varchar(255) BINARY
in MySQL and
OBJECT VARBINARY(255)
in the working hsql


Quote:
HiLo cannot be used in JTA your with user suppied connection, but it's not related.



What else should I use with my int-ID?
Or shall I use another datatype within my application?

The hilo seems to ork fine, up to now (but there are only a few entries in the database)...


--
Sven =:^)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 9:48 pm 
Beginner
Beginner

Joined: Sun Sep 21, 2003 12:19 am
Posts: 40
I had the same problem today with writing is okay but reading is not. It turned out to be if I specify 'serializable' as type without specify other db related attributes, hibernate create a VARCHAR BINARY with 255 length so all my classes won't fit.

You have to specify the column length big enough to hold your serialzation result.

Hope this help.

Here is a sample:

<property ... type="serializable">
<column ... length="9216"/>
</property>

This won't create the 9k column rather a type of Blob in Mysql, so I guess the length doesn't matter in MySQL but matter for certain version RDMS?[/code]


Top
 Profile  
 
 Post subject: Thanks a lot!
PostPosted: Tue Dec 14, 2004 5:42 am 
Newbie

Joined: Wed Sep 08, 2004 4:16 am
Posts: 5
I had the same problem and it sure was the length that was not big enough.

It would be nice to catch those EOF excpetions during the deserialization and to provide an error message that states which field that is too short.

Hibernate is a wonderful thing but when it comes to error handling there is room for improvements. A lovely example of this is Tapestry that has what they call Line-Precise-Error-Reporting.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.