CREATE_IF_MISSING feature and AggregateTestFixture

Hi, I’ve been testing some things with regard to the CREATE_IF_MISSING aggregate feature. I’ve been trying several things in a running Spring boot application+dockerized Axon server and all works well, however I can not get the unittests to work when using the AggregateTestFixture.

The aggregate only has a default public constructor. This is the only commandhandler:

public void handle(ImportOrganisationCommand cmd) {
if (id == null) {
apply(new OrganisationCreatedEvent(cmd.getOrganisation()));
} else if (!cmd.getOrganisation().equals(organisation)) {
apply(new OrganisationUpdatedEvent(cmd.getOrganisation()));

This is the test:

void test1() {
ImportOrganisationCommand cmd = new ImportOrganisationCommand(“1”, org1);
OrganisationCreatedEvent organisationCreatedEvent = new OrganisationCreatedEvent(org1);


which results in the following error:

org.axonframework.common.AxonConfigurationException: Identifier must be set after handling the message

I do not understand what the problem is ?

Hi Rob,

I don’t think this is currently an issue with the usage of the create-if-missing functionality.
It is true that this exact message will only occur if a create-or-update is in progress, but it is there to signal users that the aggregate identifier is required to be set after handling the creation.

So, I am pretty confident you might be missing an Event Sourcing Handler for the OrganisationCreatedEvent to actually set the aggregate identifier field in the aggregate.
Could you confirm this is the case?

If not, then we have some further investigating to do!


PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at

Hope to see you there!

Hi Steven,

You are absolutely right, there is no issue. I did already use the Event Sourcing handler as you mentioned, but something was wrong with my testdata, which I kept overlooking. Sorry, my bad!

Hi Rob,

No worries, stuff like that can happen!
Happy to have been of help here.