No Handler for command. The aggregate is in a different package/jar than the Springboot application

When sending the CreateAxonHealthCommand, the CommandDispatcher reports a No Handler for command: message.
Here is the Aggregate

public class AxonHealthHandler {

    private String id;

    public AxonHealthHandler(CreateAxonHealthCommand command) {

        if (StringUtils.isBlank(id)) {
            apply(new CreateAxonHealthEvent(command.getId()));

    public void on(CreateAxonHealthEvent event) {
        id = event.getId();

and the command to send;

 commandGateway.send(new CreateAxonHealthCommand(HEALTH_AGREGATE));

How AxonFramework discovers the classes annotated with @Aggrate?
currently, this aggragate class is in an other package as my Springboot application. In fact this aggregate is in a jar by itself.

Looks it’s tied to Springboot bean scan, as when setting the @ComponentScan in the Springboot applicaiton, the commend handler gets registered.

@ComponentScan(basePackageClasses = { App.class, AxonHealthHandler.class })

Hi Daniel,

As you already discovered, your “No handler” error should be fixed with a component scan. Besides a component scan, you could also use @Import(YourConfiguration.class) or a provide a starter with autoconfiguration.

However, I see some tiny issues with your code above.

  • Naming an aggregate class with Handler suffix seems kind of strange
  • Using generic classes such as String, UUID or long for aggregate identifiers is a brittle solution. It might be more elegant and robust to wrap the string inside a domain class such as AxonHealthId
  • Your id will always be null since you are checking for StringUtils.isBlank inside a constructor, so the id not yet initialized.
  • Your call commandGateway.send() actually uses a constant id, I am wondering why?


1 Like