Spring component scan / constructor injection / setter injection

When I use @Service to register my CommandHandler beans, the with
@CommandHandler annotated methods of the bean do not get registered at
the commandBus.

Using constructor injection and an explicit bean definition, cglib
throws an IllegalArgumentException: Superclass has no null
constructors but no arguments where given. Even though the constructor
arg is in the bean definition.

Is setter injection the only option for CommandHandlers?


Hi Roald,

adding a default constructor to your bean should do the trick. Axon uses CGLib to create a proxy for your command handler. CGLib creates a dynamic subclass, which diverts all calls to the original object, while also implementing the CommandHandler interface.

Constructor injection should work fine, as long as there is also a no-arg constructor available. That constructor may probably have protected visibility (not sure, though).