Hi
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
@Component("demoBean")
@Scope("session")
public class DemoBean {
@Autowired
DemoSpringBeanExample dsbe;
@Autowired
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",
"Thomas"));
return "Hello World! Comand send ";
}
}
public class KundeCommandHandler {
private Repository<Kunde> kundeRepository;
@CommandHandler
public void handle(final NeuerKundeCommand command, UnitOfWork
unitOfWork)
throws Throwable {
System.out.println("Hier command handler NeuerKunde: " +
command.getName());
AggregateIdentifier id = new
StringAggregateIdentifier(UUID.randomUUID().toString());
Kunde kunde = new Kunde(id, command.getName(),
command.getVorname());
kundeRepository.add(kunde);
}
@Required
public void setKundeRepository(Repository<Kunde> kundeRepository)
{
this.kundeRepository = kundeRepository;
}
}
public class NeuerKundeCommand {
private String name;
private String vorname;
public NeuerKundeCommand(String name, String vorname) {
this.name = name;
this.vorname = vorname;
}
public String getName() {
return name;
}
public String getVorname() {
return vorname;
}
}
and that my application-context.xml
<context:annotation-config/>
<context:component-scan base-package="ch.fabbri.jsf"/>
<context:component-scan base-package="ch.fabbri.core"/>
<axon:annotation-config/>
<axon:event-bus id="eventBus"/>
<axon:command-bus id="commandBus"/>
<bean name="axon:annotationCommandHandlerBeanPostProcessor"
class="org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor"/