Announcement Announcement Module
Collapse
No announcement yet.
SerializationException when doing deserialization using Spring Hibernate 2.0.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SerializationException when doing deserialization using Spring Hibernate 2.0.2

    Hi Folks,
    I am getting an org.hibernate.type.SerializationExceptionwhen trying to load an object using Hibernate 3.2.4SP1. I am using Spring Hibernate 2.0.2 and HQSQL running as a in-memory database. Mapping where this exception takes place is a simple one-to-one mapping (based on primary key association), as follows:

    <one-to-one name="person" class="Person"/>
    <one-to-one name="employee" class="Employee" constrained="true"/>
    <class name="person" table="PERSON">
    <id name="id" column="PERSON_ID">
    <generator class="foreign">
    <param name="property">employee</param>
    </generator>
    </id>
    ...
    <one-to-one name="employee"
    class="Employee"
    constrained="true"/>
    </class>

    Strangest thing is, when debugging through the code, I can see the rows being returned from database. The exception takes place when hibernate tries to read bytes form the results set which is returned.

    Below is a stacktrace. Any help is appreciated.

    org.springframework.orm.hibernate3.HibernateSystem Exception: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize
    Caused by: org.hibernate.type.SerializationException: could not deserialize
    at org.hibernate.util.SerializationHelper.deserialize (SerializationHelper.java:217)
    at org.hibernate.util.SerializationHelper.deserialize (SerializationHelper.java:240)
    at org.hibernate.type.SerializableType.fromBytes(Seri alizableType.java:82)
    at org.hibernate.type.SerializableType.get(Serializab leType.java:39)
    at org.hibernate.type.NullableType.nullSafeGet(Nullab leType.java:163)
    at org.hibernate.type.NullableType.nullSafeGet(Nullab leType.java:154)
    at org.hibernate.loader.Loader.getKeyFromResultSet(Lo ader.java:1097)
    at org.hibernate.loader.Loader.getRowFromResultSet(Lo ader.java:565)
    at org.hibernate.loader.Loader.doQuery(Loader.java:70 1)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:222 0)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2104)
    at org.hibernate.loader.Loader.list(Loader.java:2099)
    at org.hibernate.loader.criteria.CriteriaLoader.list( CriteriaLoader.java:94)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1569)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl. java:283)
    .
    .
    .
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:367)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:333)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:60)
    at java.lang.reflect.Method.invoke(Method.java:391)
    at junit.framework.TestCase.runTest(TestCase.java:154 )
    at junit.framework.TestCase.runBare(TestCase.java:127 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: java.io.StreamCorruptedException: invalid stream header
    at java.io.ObjectInputStream.readStreamHeader(ObjectI nputStream.java:770)
    at java.io.ObjectInputStream.<init>(ObjectInputStream .java:286)
    at org.hibernate.util.SerializationHelper$CustomObjec tInputStream.<init>(SerializationHelper.java:252)
    at org.hibernate.util.SerializationHelper.deserialize (SerializationHelper.java:209)
    ... 39 more

  • #2
    Does the Employee class implement Serializable?

    Comment


    • #3
      Yes both classes implement the Serializable class. I found a couple of threads on the web concerning this issue, there are different opinions, some mention that their problem was caused due to driver implementation problem, some mention the string/text type conversion problem. see following links for example:
      http://myeclipseide.com/PNphpBB2-pri...-start-15.html
      http://forum.java.sun.com/thread.jsp...sageID=9505056

      Comment

      Working...
      X