org.hibernate.type.SerializationException: could not deserialize

Hibernate JIRA | Janario Oliveira | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    When I have the following mapping: @ElementCollection @CollectionTable @Enumerated(EnumType.STRING) private Map<LocalDateTime, SomeEnum> map = new HashMap<>(); @Converter(autoApply = true) public class LocalDateTimeAttributeConverter implements AttributeConverter<LocalDateTime, Timestamp> {...} Hibernate fails to autoapply the attributeConverter and leave it as binary. So when I execute a query it throws an exception trying to convert to binary Exception in thread "main" org.hibernate.type.SerializationException: could not deserialize at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:243) at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:287) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:138) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:113) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:27) at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:53) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:241) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:237) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:227) at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:839) at org.hibernate.collection.internal.PersistentMap.readFrom(PersistentMap.java:265) at org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl.finishUpRow(CollectionReferenceInitializerImpl.java:77) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:108) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:112) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85) at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:82) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682) at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75) at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1922) at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:546) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:248) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:542) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:133) at org.hibernate.collection.internal.PersistentMap.toString(PersistentMap.java:250) at java.lang.String.valueOf(String.java:2994) at java.io.PrintStream.println(PrintStream.java:821) at br.com.tecsinapse.jpa.model.Main.main(Main.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.io.StreamCorruptedException: invalid stream header: 32303135 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299) at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218) ... 33 more

    Hibernate JIRA | 1 year ago | Janario Oliveira
    org.hibernate.type.SerializationException: could not deserialize
  2. 0

    When I have the following mapping: @ElementCollection @CollectionTable @Enumerated(EnumType.STRING) private Map<LocalDateTime, SomeEnum> map = new HashMap<>(); @Converter(autoApply = true) public class LocalDateTimeAttributeConverter implements AttributeConverter<LocalDateTime, Timestamp> {...} Hibernate fails to autoapply the attributeConverter and leave it as binary. So when I execute a query it throws an exception trying to convert to binary Exception in thread "main" org.hibernate.type.SerializationException: could not deserialize at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:243) at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:287) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:138) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:113) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:27) at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:53) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:241) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:237) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:227) at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:839) at org.hibernate.collection.internal.PersistentMap.readFrom(PersistentMap.java:265) at org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl.finishUpRow(CollectionReferenceInitializerImpl.java:77) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:108) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:112) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85) at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:82) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682) at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75) at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1922) at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:546) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:248) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:542) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:133) at org.hibernate.collection.internal.PersistentMap.toString(PersistentMap.java:250) at java.lang.String.valueOf(String.java:2994) at java.io.PrintStream.println(PrintStream.java:821) at br.com.tecsinapse.jpa.model.Main.main(Main.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.io.StreamCorruptedException: invalid stream header: 32303135 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299) at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218) ... 33 more

    Hibernate JIRA | 1 year ago | Janario Oliveira
    org.hibernate.type.SerializationException: could not deserialize
  3. 0

    Hibernate 5 java.time issue on postgres

    Stack Overflow | 5 months ago | Arash
    java.io.StreamCorruptedException: invalid stream header: 32303135
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    H2DB : column[UUID]("NAME") fails with Deserialization failed unless setting O.DBType("UUID")

    GitHub | 2 years ago | petervandenabeele
    org.h2.jdbc.JdbcSQLException: Deserialization failed, cause: "java.io.StreamCorruptedException: invalid stream header: 91502BE7" [90027-186]
  6. 0

    invalid stream header: CAFEBABE exception in applet while reading from database through java code

    Stack Overflow | 2 years ago
    java.io.StreamCorruptedException: invalid stream header: CAFEBABE
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.StreamCorruptedException

    invalid stream header: 32303135

    at java.io.ObjectInputStream.readStreamHeader()
  2. Java RT
    ObjectInputStream.<init>
    1. java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806)
    2. java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
    2 frames
  3. Hibernate
    PersistentMap.readFrom
    1. org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309)
    2. org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299)
    3. org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218)
    4. org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:287)
    5. org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:138)
    6. org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:113)
    7. org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:27)
    8. org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:53)
    9. org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)
    10. org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:241)
    11. org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:237)
    12. org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:227)
    13. org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:839)
    14. org.hibernate.collection.internal.PersistentMap.readFrom(PersistentMap.java:265)
    14 frames
  4. org.hibernate.loader
    AbstractLoadPlanBasedCollectionInitializer.initialize
    1. org.hibernate.loader.plan.exec.process.internal.CollectionReferenceInitializerImpl.finishUpRow(CollectionReferenceInitializerImpl.java:77)
    2. org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:108)
    3. org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:112)
    4. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)
    5. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:85)
    6. org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:82)
    6 frames
  5. Hibernate
    PersistentMap.toString
    1. org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682)
    2. org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75)
    3. org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1922)
    4. org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:546)
    5. org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:248)
    6. org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:542)
    7. org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:133)
    8. org.hibernate.collection.internal.PersistentMap.toString(PersistentMap.java:250)
    8 frames
  6. Java RT
    PrintStream.println
    1. java.lang.String.valueOf(String.java:2994)
    2. java.io.PrintStream.println(PrintStream.java:821)
    2 frames
  7. br.com.tecsinapse
    Main.main
    1. br.com.tecsinapse.jpa.model.Main.main(Main.java:31)
    1 frame
  8. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  9. IDEA
    AppMain.main
    1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    1 frame