EventStore doesn't get injected into a command handler of an aggregate

Hi there,

I’ve stumbled on a problem with Axon. I have a CommandHandler on an aggregate that receives two the parameters. The first parameter, obviously is the command, and the second parameter is an EventStore. So the signature basically looks like this:


public void handle(AssignRight command, EventStore eventStore) {


I’m using this in a unit test with a default configuration like this:


EventStorageEngine eventStorageEngine = new InMemoryEventStorageEngine();

Configuration configuration = DefaultConfigurer
.configureEmbeddedEventStore(config -> eventStorageEngine)



When I now send a command to the aggregate with this:




I get the following exception:

org.axonframework.test.FixtureExecutionException: No resource of type [org.axonframework.eventsourcing.eventstore.EventStore] has been registered. It is required for one of the handlers being executed.

at org.axonframework.test.FixtureResourceParameterResolverFactory$FailingParameterResolver.resolveParameterValue(
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.resolveParameterValues(
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(
at org.axonframework.messaging.annotation.WrappedMessageHandlingMember.handle(
at org.axonframework.commandhandling.model.inspection.AnnotatedAggregate.lambda$handle$3(
at org.axonframework.commandhandling.model.inspection.AnnotatedAggregate$$Lambda$150/ Source)
at org.axonframework.commandhandling.model.AggregateLifecycle.executeWithResult(
at org.axonframework.commandhandling.model.inspection.AnnotatedAggregate.handle(
at org.axonframework.commandhandling.model.LockAwareAggregate.handle(


So obviously there is no EventStore registered in the resources list.

If I use the type EventBus for the second parameter, the parameter gets injected into the command handler. So did I miss some concept that forbids the use on an EventStore by an aggregates command handler? Or is this a bug?

Help’s appreciated.

Thanks in advance,


Hi Frank,

you’ve hit an exception to the rule, I think. Some would call it a bug ;-).

The injection mechanism allows you to inject components that have been defined in the configuration. However, the EventStore is not registered in the configuration as an EventStore, but as EventBus (which then has an implementation that also implements Event Store). That’s why it only works when looking for the Event Bus.

I think a solution for this in Axon would be pretty simple, actually. And it does seem like a good idea to allow for the EventStore type to be injected as a parameter…

A workaround is pretty simple. Just call:
configurer.registerComponent(EventStore.class, Configuration::eventStore);

the eventStore() method on the configuration uses the EventBus type to retrieve the implementation, and checks whether it actually is an Event Store implementation.