Missing SpringBeanParameterResolver during AnnotatedHandlerInspector#initializeMessageHandlers() call

Hi all,

I am wondering at which point the SpringBeanParameterResolver is registered?

The issue I’m having is that when I define my aggregate as:


public class Visitor {

  private MyService service;

  public Visitor(CreateVisitorCommand command, MyService service) {
    this.service = service;
    apply(new VisitorCreatedEvent(command.getId(), command.getVisitorName()));


MyService is a service bean that is registered in the Spring application context.

I define a GenericJpaRepository for it:

@Bean publicGenericJpaRepository<Visitor> visitorRepository() { return new GenericJpaRepository<>(entityManagerProvider, Visitor.class, eventStore); }

During the Spring context initialization, with such repository definition, I’m getting an exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘visitorRepository’ defined in class path resource [AxonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.commandhandling.model.GenericJpaRepository]: Factory method ‘visitorRepository’ threw exception; nested exception is org.axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolver parameter 1 (MyService) in handler public Visitor(CreateVisitorCommand, MyService).


If I remove the MyService constructor parameter in the Visitor class, the application starts properly.
During debugging, I noticed that the SpringBeanParameterResolver is added to parameterResolverFactory at a later moment in time, and it has the bean MyService instantiated.

Is there a way to overcome this issue and have the SpringBeanParameterResolver with configured applicationContext available before AnnotatedMessageHandlingMember is resolved for the aggregate with the dependency? Why is it even resolved during the repository bean creation?

Thank you for your help and answers!

Kind regards,


You need to pass the ParameterResolverFactory as a parameter to the constructor of the GenericJpaRepository. You should be able to autowire it.

Hope that helps,


Hi Allard,

Yes, autowiring ParameterResolverFactory and passing it as an argument to GenericJpaRepository constructor has helped solve the issue.

Thank you for your help and quick response!