Axon, Spring, JSF and me - No handler was subscribed to commands of type [NeuerKundeCommand]


I try to get my own sample running - Axon with Spring - and i'm
running against a wall with my configuration or the implementation (5
lines of code ;-).

org.axonframework.commandhandling.NoHandlerForCommandException: No
handler was subscribed to commands of type [NeuerKundeCommand]

What i'm trying to do is: i want to send a the command
[NeuerKundeCommand] from my JSF Backing Bean. I was thinking, that the
@CommandHandler Annotation and the "<axon:command-bus id="commandBus"/

" is enough for the job... any idea where i should take a look?

Cheers, Reto

public class DemoBean {

    DemoSpringBeanExample dsbe;

    CommandBus commandBus;

        public String getMessage() {

          if ( dsbe == null) { return "Merdé - DI not working";}

          if (commandBus == null) { return "HOLYMOLY from DemoBean -
Command Bus is NULL - SI4";}
          commandBus.dispatch( new NeuerKundeCommand("Lanz",
          return "Hello World! Comand send ";

public class KundeCommandHandler {

    private Repository<Kunde> kundeRepository;

    public void handle(final NeuerKundeCommand command, UnitOfWork
            throws Throwable {
        System.out.println("Hier command handler NeuerKunde: " +

        AggregateIdentifier id = new

        Kunde kunde = new Kunde(id, command.getName(),

    public void setKundeRepository(Repository<Kunde> kundeRepository)
        this.kundeRepository = kundeRepository;

public class NeuerKundeCommand {

    private String name;
    private String vorname;

    public NeuerKundeCommand(String name, String vorname) { = name;
        this.vorname = vorname;

    public String getName() {
        return name;

    public String getVorname() {
        return vorname;

and that my application-context.xml


    <context:component-scan base-package="ch.fabbri.jsf"/>
    <context:component-scan base-package="ch.fabbri.core"/>


    <axon:event-bus id="eventBus"/>
    <axon:command-bus id="commandBus"/>

    <bean name="axon:annotationCommandHandlerBeanPostProcessor"


Hi Reto,

the problem is that the bean defining the @CommandHandler is a session scoped bean. This means that at initialization time, there is no instance of that bean to wire with the command bus. Once a bean is constructed, it is not automatically subscribed. That wouldn’t make sense, since you can have multiple concurrent sessions, but only a single handler per command type.

What you’d need to do is create a singleton bean for the @CommandHandler methods, and call that bean from your session scoped bean.
Note that you don’t need to configure an “AnnotationCommandHandlerBeanPostProcessor” if you also have axon:annotation-config/ in your application context. They do the same thing.



Thanks a lot Allard, that makes some sense :wink: