Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not deserialize org.hibernate.type.SerializationException

Please help- My application was working fine until today. Today I got the exception "could not deserialize". java.io.eofException. And sometimes I was able to get the data. The problem was intermittent. What could be the issue here?

@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class Filter {
private int id;
    private String name;
    private User user;
    private NameValue[][] filterMap;


    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    @ManyToOne(
            targetEntity = User.class
    )
    @JoinColumn(name="userName")
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }
    @Lob
        public NameValue[][] getFilterMap() {
        return filterMap;
    }
    public void setFilterMap(NameValue[][] filterMap) {
        this.filterMap = filterMap;
    }
like image 880
Jess Avatar asked Oct 30 '25 09:10

Jess


1 Answers

This probably happens because the object can be cached, and you must have configured the cache to overflow to disk (or any other storage).

The problem happens when you try to serialize or deserialize the class, and one or more of the following happen:

  1. The class or any of the fields (such as User) don't implement Serializable
  2. The class has changed since the last deploy and java generates a new serialVersionUID. When java tries to load an object that was previously on the disk cache, the serialVersionUID don't match and the error is thrown.
  3. You're using a different JVM which generates a different serialVersionUID
like image 175
Augusto Avatar answered Nov 02 '25 11:11

Augusto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!