Steps: After the snapshot is created and the next command is delivered to the aggregate, the event-sourcing repository fails to load the aggregate from the snapshot. This happens due to serialization issues for the DataEntryAggregate. A short check in the snapshot representation (e.G. in a JPA event store) showed, that the snapshot contains EMPTY payload (but rathershould contain the dataEntryIdentity and the deleted flag).
Steps to fix
Write a serialization/deserialization test for the aggregate
Fix the serialization
Side not
Probably the same problem exists for the other snapshotter (e.g. for TaskAggregate)
Expected behaviour
The event-sourcing can restore aggregate from the snapshot.
Actual behaviour
Exception
2024-04-12T07:08:00.740Z INFO 1 --- [ad | producer-1] o.a.k.c.p.internals.TransactionManager : [Producer clientId=producer-1] ProducerId set to 30 with epoch 0
2024-04-12T07:08:01.676Z WARN 1 --- [nio-8080-exec-1] o.a.m.command.AbstractRepository : Exception occurred while trying to load/create aggregate with identifier [foo.bar.foo.bar.domain.model.foo.bar#1c4569b9-8a36-441c-95cf-d68516bb8324].
org.axonframework.eventsourcing.IncompatibleAggregateException: Aggregate identifier must be non-null after applying a snapshot. Make sure the aggregate identifier is included in the snapshot that is used to restore the aggregate from. Note the identifier may be missing due to your serializer being unable to find the private field(s) of your aggregate.
at org.axonframework.eventsourcing.EventSourcedAggregate.publish(EventSourcedAggregate.java:256) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
at org.axonframework.eventsourcing.EventSourcedAggregate.lambda$initializeState$0(EventSourcedAggregate.java:296) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.inspection.AnnotatedAggregate.lambda$execute$2(AnnotatedAggregate.java:349) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.AggregateLifecycle.lambda$execute$0(AggregateLifecycle.java:189) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.Scope.executeWithResult(Scope.java:111) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.AggregateLifecycle.execute(AggregateLifecycle.java:188) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.inspection.AnnotatedAggregate.execute(AnnotatedAggregate.java:349) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.EventSourcedAggregate.initializeState(EventSourcedAggregate.java:293) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.EventSourcingRepository.doLoadAggregate(EventSourcingRepository.java:158) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.EventSourcingRepository.lambda$doLoadWithLock$0(EventSourcingRepository.java:138) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.Span.runSupplier(Span.java:163) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.EventSourcingRepository.doLoadWithLock(EventSourcingRepository.java:138) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.CachingEventSourcingRepository.doLoadWithLock(CachingEventSourcingRepository.java:120) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.eventsourcing.CachingEventSourcingRepository.doLoadWithLock(CachingEventSourcingRepository.java:40) ~[axon-eventsourcing-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.LockingRepository.doLoadOrCreate(LockingRepository.java:153) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.LockingRepository.doLoadOrCreate(LockingRepository.java:60) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at org.axonframework.modelling.command.AbstractRepository.lambda$loadOrCreate$8(AbstractRepository.java:176) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220) ~[na:na]
at org.axonframework.modelling.command.AbstractRepository.loadOrCreate(AbstractRepository.java:172) ~[axon-modelling-4.9.2.jar!/:4.9.2]
at io.holunda.polyflow.datapool.core.business.CreateOrUpdateCommandHandler.createOrUpdate(CreateOrUpdateCommandHandler.kt:38) ~[polyflow-datapool-core-4.1.3.jar!/:4.1.3]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(AnnotatedMessageHandlingMember.java:153) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(WrappedMessageHandlingMember.java:64) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.lambda$handle$1(TracingHandlerEnhancerDefinition.java:84) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.Span.runCallable(Span.java:132) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.TracingHandlerEnhancerDefinition$1.handle(TracingHandlerEnhancerDefinition.java:84) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.annotation.NoMoreInterceptors.handle(NoMoreInterceptors.java:46) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.AnnotationCommandHandlerAdapter.handle(AnnotationCommandHandlerAdapter.java:125) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.AnnotationCommandHandlerAdapter.handle(AnnotationCommandHandlerAdapter.java:45) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:57) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.interceptors.CorrelationDataInterceptor.handle(CorrelationDataInterceptor.java:67) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:77) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.SimpleCommandBus.lambda$handle$2(SimpleCommandBus.java:200) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.Span.runSupplier(Span.java:163) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:191) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:165) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.SimpleCommandBus.lambda$dispatch$1(SimpleCommandBus.java:131) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.tracing.Span.run(Span.java:101) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:125) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.gateway.AbstractCommandGateway.send(AbstractCommandGateway.java:76) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at org.axonframework.commandhandling.gateway.DefaultCommandGateway.send(DefaultCommandGateway.java:83) ~[axon-messaging-4.9.2.jar!/:4.9.2]
at io.holunda.polyflow.datapool.sender.SimpleDataEntryCommandSender.sendDataEntryChange(SimpleDataEntryCommandSender.kt:101) ~[polyflow-datapool-sender-4.1.3.jar!/:4.1.3]
at foo.bar.infrastructure.polyflow.DatapoolSenderService.send(DatapoolSenderService.java:61) ~[mytask-integration-1.2.0.jar!/:na]
at foo.bar.infrastructure.polyflow.DatapoolSenderService.completeBusinessProcess(DatapoolSenderService.java:44) ~[mytask-integration-1.2.0.jar!/:na]
at foo.bar.foo.bar.application.service.BusinessProcessService.finishBusinessProcess(BusinessProcessService.java:32) ~[classes!/:1.8.0]
at foo.bar.foo.bar.application.service.foo.barCompletionService.onCompletefoo.bar(foo.barCompletionService.java:40) ~[classes!/:1.8.0]
at foo.bar.foo.bar.infrastructure.process.camunda.listener.ProcessEndListener.notify(ProcessEndListener.java:24) ~[classes!/:1.8.0]
Steps to reproduce
DataEntryAggregate
. A short check in the snapshot representation (e.G. in a JPA event store) showed, that the snapshot contains EMPTY payload (but rathershould contain the dataEntryIdentity and the deleted flag).Steps to fix
Side not
Expected behaviour
The event-sourcing can restore aggregate from the snapshot.
Actual behaviour
Exception
(In case of exceptions provide full stack trace)