I try to inject a spring bean (JythonObjectFactory) as a parameter in @EventSourcingHandler, but I get error like “Caused by: org.axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolver parameter 1 (JythonObjectFactory) in handler”
If I understood correctly, @EventSourcingHandler’s MultiParameterResolverFactory should use SpringBeanParameterResolverFactory for spring bean injection
Am I missing something in the configuration axon ?
I believe there was an issue in 3.0 that the SpringBeanParameterResolver wasn’t created for event handling/sourcing functions, but that should’ve been fixed some time ago.
For testing I just ran the axon-bank example on 3.0.3 and the SpringBeanParameterResolverFactory is part of the MultiParameterResolverFactory.
As far as my understanding goes, if you’re running a Spring application, the SpringParameterResolverFactoryBean should automatically create a SpringBeanParameterResolverFactory.
Could you verify the JythonObjectFactory can be autowired in to other places?
from you screenshot, I conclude that there is no SpringParameterResolver in the list of resolvers. This would mean Spring bean injection isn’t supported in your setup.
Do you define any repositories yourself in the application context?
Yes, I defined repository with ehcache in my config without ParameterResolverFactory in the constructor param of my repository.
.
I just injected it (it should be defined already in axon config context) in my parameters like:
@Bean
public Repository<BusinessStreamRun> businessStreamRunRepository(AggregateFactory<BusinessStreamRun> businessStreamRunAggregateFactory,
EventStore eventStore,
ParameterResolverFactory parameterResolverFactory,
Cache businessStreamRunCache) {
return new CachingEventSourcingRepository<>(businessStreamRunAggregateFactory,
eventStore,
new PessimisticLockFactory(),
businessStreamRunCache,
parameterResolverFactory,
NoSnapshotTriggerDefinition.INSTANCE);
}