JsonMappingException while deserialize Snapshot Event

The Exception Message is as follow:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class org.axonframework.domain.EventContainer]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)

but when i use @JsonIgnoreProperties({“eventContainer”}) to ignore EventContainer,then i got another exception:

java.lang.IllegalStateException: Aggregate is already initialized
at org.axonframework.common.Assert.state(Assert.java:40) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot.initializeState(AbstractEventSourcedAggregateRoot.java:62) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.eventsourcing.EventSourcingRepository.doLoad(EventSourcingRepository.java:177) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.eventsourcing.EventSourcingRepository.doLoad(EventSourcingRepository.java:56) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.repository.AbstractRepository.load(AbstractRepository.java:76) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.repository.LockingRepository.load(LockingRepository.java:102) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.repository.AbstractRepository.load(AbstractRepository.java:86) ~[axon-core-2.4.4.jar:2.4.4]
at org.axonframework.repository.AbstractRepository.load(AbstractRepository.java:39) ~[axon-core-2.4.4.jar:2.4.4]

I just migrate from XStreamSerializer to JacksonSerializer 。

Thanks!

Hi,

The JacksonSerializer has some requirements on the objects to be serialized. The aggregate (and saga) typically don’t fulfill al these requirements. It’s recommended to use a more general purpose serializer for these objects. Events, though, are very suitable to serialize using Jackson.

Cheers,

Allard

so we should not store playload of Snapshot Event in json ?

在 2016年5月12日星期四 UTC+8上午4:12:37,Allard Buijze写道:

No, unless you are sure that the payload (by default, that’s your aggregate itself) is compatible with Jackson. I wouldn’t want to change my model for that…