Hello,
I have encountered the AggregateIdentifierNotInitializedException problem, which I am not able to solve. I have tried everything found on this group, and still not sure why it’s not working.
The exception occurs after creating the Aggregate, when I try to update it via a Command by using repository load in command handler.
I am using Axon 2.4.5 and Spring Boot 1.4.2.
Below is how I create the Aggregate
public class IdentityAgg extends AbstractAnnotatedAggregateRoot implements Serializable {
private static final long serialVersionUID = 8832894803205334145L;
@AggregateIdentifier
private String id;
private String type;
private String name;
private List<Contact> contactList;
public IdentityAgg() {}
public IdentityAgg(String id, String type, String name) {
apply(new IdentityCreatedEvent(id, type, name));
}
@EventSourcingHandler
public void handle(IdentityCreatedEvent event) {
this.id = event.getIdentityId();
this.type = event.getType();
this.name = event.getName();
}
And this is how I update the Aggregate
@Component
public class ContactCommandHandler {
@Autowired
private Repository repository;
@CommandHandler
public void handle(RegisterNewContactCommand registerNewContactCommand) throws OPNSException {
IdentityAgg identityAggToAddWithin = (IdentityAgg) repository.load(registerNewContactCommand.getIdentityId()); // this line is throwing the exception
identityAggToAddWithin.addContact(registerNewContactCommand.getIdentityId(), registerNewContactCommand.getContact());
}