java.io.StreamCorruptedException: invalid stream header

Hibernate JIRA | David Mansfield | 8 years ago
  1. 0

    after upgrading from annotations 3.3.0GA to 3.3.1GA, my mapped collection (ManyToMany) is broken. i've identified the commit that broke it: http://fisheye.jboss.com/browse/Hibernate/annotations/trunk/src/java/org/hibernate/cfg/annotations/MapBinder.java?r1=12963&r2=14425 The issue is that unless the type is given now expliticly in the @MapKey's @Type, the code now assumes a 'Serializable' type, and attempts to deserialize an object stream from the database column value. the exact exception is: java.io.StreamCorruptedException: invalid stream header at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277) at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252) at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209) at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240) at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82) at org.hibernate.type.SerializableType.get(SerializableType.java:39) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163) ... The fix is simple: if @Type is NOT given in the @MapKey annotation, keep the old behavior which at least tries to set the type, even if it may not work in all situations. The attached patch fixes the problem for me. In my particular situation, the map key type is a java.lang.Enum. Here's what my annotated property looks like: @ManyToMany @JoinTable( name="chargeback_owner" ,joinColumns=@JoinColumn(name="person_id",referencedColumnName="person_id") ,inverseJoinColumns=@JoinColumn(name="owner_person_id") ) @MapKey(columns=@Column(name="owner_type_cd"),targetElement=ChargebackOwnerType.class) @Enumerated(EnumType.STRING) @Sort(type=SortType.NATURAL) private SortedMap<ChargebackOwnerType,Person> owners = new TreeMap<ChargebackOwnerType, Person>();

    Hibernate JIRA | 8 years ago | David Mansfield
    java.io.StreamCorruptedException: invalid stream header
  2. 0

    after upgrading from annotations 3.3.0GA to 3.3.1GA, my mapped collection (ManyToMany) is broken. i've identified the commit that broke it: http://fisheye.jboss.com/browse/Hibernate/annotations/trunk/src/java/org/hibernate/cfg/annotations/MapBinder.java?r1=12963&r2=14425 The issue is that unless the type is given now expliticly in the @MapKey's @Type, the code now assumes a 'Serializable' type, and attempts to deserialize an object stream from the database column value. the exact exception is: java.io.StreamCorruptedException: invalid stream header at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277) at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252) at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209) at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240) at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82) at org.hibernate.type.SerializableType.get(SerializableType.java:39) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163) ... The fix is simple: if @Type is NOT given in the @MapKey annotation, keep the old behavior which at least tries to set the type, even if it may not work in all situations. The attached patch fixes the problem for me. In my particular situation, the map key type is a java.lang.Enum. Here's what my annotated property looks like: @ManyToMany @JoinTable( name="chargeback_owner" ,joinColumns=@JoinColumn(name="person_id",referencedColumnName="person_id") ,inverseJoinColumns=@JoinColumn(name="owner_person_id") ) @MapKey(columns=@Column(name="owner_type_cd"),targetElement=ChargebackOwnerType.class) @Enumerated(EnumType.STRING) @Sort(type=SortType.NATURAL) private SortedMap<ChargebackOwnerType,Person> owners = new TreeMap<ChargebackOwnerType, Person>();

    Hibernate JIRA | 8 years ago | David Mansfield
    java.io.StreamCorruptedException: invalid stream header
  3. 0

    How to deal with postgresql data types that Hibernate can not deserialize?

    Stack Overflow | 3 years ago | Jeremy
    java.io.StreamCorruptedException: invalid stream header: 30313033
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    org.hibernate.type.SerializationException and java.io.StreamCorruptedException: invalid stream header | dwuysan

    wordpress.com | 11 months ago
    java.io.StreamCorruptedException: invalid stream header: 52657175
  6. 0

    February | 2012 | dwuysan

    wordpress.com | 8 months ago
    java.io.StreamCorruptedException: invalid stream header: 52657175

  1. tererecool 2 times, last 2 months ago
  2. Stefan Braune 4 times, last 4 months ago
  3. RoiOtero 1 times, last 5 months ago
  4. MoYapro 15 times, last 5 months ago
46 unregistered visitors
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

    at java.io.ObjectInputStream.readStreamHeader()
  2. Java RT
    ObjectInputStream.<init>
    1. java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
    2. java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
    2 frames
  3. Hibernate
    SerializationHelper.deserialize
    1. org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:252)
    2. org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:209)
    3. org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:240)
    3 frames
  4. Hibernate
    NullableType.nullSafeGet
    1. org.hibernate.type.SerializableType.fromBytes(SerializableType.java:82)
    2. org.hibernate.type.SerializableType.get(SerializableType.java:39)
    3. org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
    3 frames