OUT_OF_RANGE: [AXONIQ-2000] Invalid sequence number 0 for aggregate

Hello, I’m quiet new to axon framework so pardon my basic question
I’m receiving this error [AXONIQ-2000] Invalid sequence number 0 for aggregate while everything is logged showing that the application is going with the flow correctly

public class OrderEventHandling {
    public void on(OrderCreatedEvent event) {
        OrderEntity orderEntity = new OrderEntity();
        BeanUtils.copyProperties(event, orderEntity);
        LOGGER.info("+ Event Handled ");

public class CreateOrderCommandHandler {
    private String userID;

    public CreateOrderCommandHandler(CreateOrderCommand createOrderCommand) {
        OrderCreatedEvent orderCreatedEvent = new OrderCreatedEvent();
        BeanUtils.copyProperties(createOrderCommand, orderCreatedEvent);
        LOGGER.info("+ Command Handler" + orderCreatedEvent.toString());

    public void on(OrderCreatedEvent event) {
        LOGGER.info("+ OrderCreatedEvent Has been event sourced");
        this.userID = event.getUserID();


The logs

2022-04-03 22:11:36.737  INFO 616831 --- [mandProcessor-0] c.e.a.o.c.e.OrderEventHandling           : + Command HandlerOrderCreatedEvent(userID=27b95829-4f3f-4ddf-8983-151ba010e35b, orderID=037ec3f7-eebb-48ed-9235-b4a1ed528924, productID=ddc2594f-3d90-4269-8547-245d2742b74e, quantity=2, addressID=This is a faw believe it, orderStatus=CREATED)
2022-04-03 22:11:36.739  INFO 616831 --- [mandProcessor-0] c.e.a.o.c.e.OrderEventHandling           : + OrderCreatedEvent Has been event sourced
2022-04-03 22:11:36.758  INFO 616831 --- [mandProcessor-0] c.e.a.o.c.e.OrderEventHandling           : + Event Handled
2022-04-03 22:11:36.812 ERROR 616831 --- [nio-9080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.axonframework.commandhandling.CommandExecutionException: OUT_OF_RANGE: [AXONIQ-2000] Invalid sequence number 0 for aggregate 27b95829-4f3f-4ddf-8983-151ba010e35b, expected 1] with root cause

Okay so after some reading ,trial and error I found out that the aggregate Identifier has to be unique per command to prevent more than one thread from accessing the same aggregate so I changed the identifier to point at the orderID and the error was gone.

My misconception: aggregates is stored and grouped by the identifier :slight_smile: