Using Akka persistence I get this exception:
Caused by: akka.persistence.typed.internal.JournalFailureException: Exception during recovery. Last known sequence number [0]. PersistenceId [PersistenceExample], due to: Cannot construct instance of
com.exercisePersistence.simpleExample.MyPersistentBehavior$Added
(although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"data":"data1"}"; line: 1, column: 2] at akka.persistence.typed.internal.ReplayingEvents.onRecoveryFailure(ReplayingEvents.scala:221) at akka.persistence.typed.internal.ReplayingEvents.onJournalResponse(ReplayingEvents.scala:143) ... 26 common frames omittedCaused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of
com.exercisePersistence.simpleExample.MyPersistentBehavior$Added
(although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (byte[])"{"data":"data1"}"; line: 1, column: 2]
The class Added that give me exception is:
public class MyPersistentBehavior
extends EventSourcedBehavior<MyPersistentBehavior.Command,
MyPersistentBehavior.Event, MyPersistentBehavior.State> {
// COMMAND
interface Command {}
public static class Add implements Command {
public final String data;
public Add(String data) {
this.data = data;
}
}
...
}
File reference.conf
akka {
actor {
serializers {
jackson-json = "akka.serialization.jackson.JacksonJsonSerializer"
jackson-cbor = "akka.serialization.jackson.JacksonCborSerializer"
proto = "akka.remote.serialization.ProtobufSerializer"
}
serialization-bindings {
"com.exercisePersistence.simpleExample.MyPersistentBehavior" = jackson-json
"com.exercisePersistence.simpleExample.MyPersistentBehavior$Added" = jackson-json
#"docs.serialization.CborSerializable" = jackson-cbor
"com.google.protobuf.Message" = proto
}
}
akka.serialization.jackson {
jackson-json-message {
serialization-features {
WRITE_DATES_AS_TIMESTAMPS = on
}
}
jackson-json-event {
serialization-features {
WRITE_DATES_AS_TIMESTAMPS = off
}
}
}
persistence {
journal {
plugin = "leveldb"
leveldb {
dir = "target/persistence/journal"
}
}
snapshot-store.local.dir = "target/persistence/snapshots"
}
}
leveldb {
dir = "target/persistence/journal"
checksum: "off"
class: "akka.persistence.journal.leveldb.LeveldbJournal"
dir: "target/persistence/journal"
fsync: "on"
native: "on"
plugin-dispatcher : "akka.persistence.dispatchers.default-plugin-dispatcher"
replay-dispatcher : "akka.persistence.dispatchers.default-replay-dispatcher"
}
If want to clone the project this is the Github link: https://github.com/Mazzotta13/AkkaTutorial.git