-1

So i'm trying to realize akka persistance, but I have an error: Persistence failure when replaying events for persistenceId [1]. Last known sequence number [0] java.io.InvalidClassException: kz.dar.arena.domain.Bullet$Evt; local class incompatible: stream classdesc serialVersionUID = -5880771744357396366, local class serialVersionUID = 1502307324601793787

what is the problem?

UPD: I've solved this problem. I just cleared journal

ifog
  • 11
  • 4
  • What is your `akka.persistence` configuration in `resources`? – Luca T. Aug 20 '18 at 15:02
  • i've used basic config from akka documentation. akka.persistence.journal.plugin = "akka.persistence.journal.leveldb" akka.persistence.snapshot-store.plugin = "akka.persistence.snapshot-store.local" akka.persistence.journal.leveldb.dir = "target/example/journal" akka.persistence.snapshot-store.local.dir = "target/example/snapshots" akka.persistence.journal.leveldb.native = false – ifog Aug 20 '18 at 15:39

1 Answers1

0

I see that you solved it but let me explain what is wrong:

You are using Java serialization to serialize the events to bytes to store in the journal. Java serialization by default decides how to serialize the data based on the structure of the class, this means that if you change the structure of the class (add a field, remove a field, rename a field etc.) it may not know how to deserialize data. The serialVersionUID field is like a protocol version number that makes it easy for the serialization library to know that the version of the data is incompatible with the class (see more here: What is a serialVersionUID and why should I use it? )

Most importantly you should almost never use Java serialization for Akka persistence or you will have problems in the future. Read more in this section of the Akka docs: https://doc.akka.io/docs/akka/current/persistence-schema-evolution.html#picking-the-right-serialization-format

johanandren
  • 10,964
  • 1
  • 20
  • 28