You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2024-11-05 | 09:47:44.782 | ERROR | http-nio-8080-exec-6 | o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.axonframework.test.FixtureExecutionException: No resource of type [com.example.MyBean] has been registered. It is required for one of the handlers being executed.] with root cause
org.axonframework.test.FixtureExecutionException: No resource of type [com.example.MyBean] has been registered. It is required for one of the handlers being executed.
at org.axonframework.test.FixtureResourceParameterResolverFactory$FailingParameterResolver.resolveParameterValue(FixtureResourceParameterResolverFactory.java:58)
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.resolveParameterValues(AnnotatedMessageHandlingMember.java:177)
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(AnnotatedMessageHandlingMember.java:153)
at io.holixon.axon.projection.adhoc.EventApplier.applyEvent(EventApplier.kt:33)
The underlying issues lies by directly instantiating ClasspathParameterResolverFactory here:
val parameterResolverFactory =ClasspathParameterResolverFactory.forClass(inspectedType)
where as for a usage with Spring we would need a MultiParameterResolverFactory which is set up with additional Spring specific resolvers (see how Axon does it here)
Solution: When running with Spring it should reuse the existing instance of ParameterResolverFactory in the application context.
Wanted Behaviour
The Spring bean (which is declared and registered in the application context) is resolved and the message handler method called.
Possible Workarounds
Use workaround such as a application context provider to statically gain access the Spring application context and thus retrieving the required beans from the handler method.
The text was updated successfully, but these errors were encountered:
I was solving the same requirement for a client of mine when I stumbled upon your work here and gave it a try.
Scenario
I would like to declare custom Spring beans to be injected in the
@MessageHandler
event handling methods, e.g.:as supported for regular Axon event handlers ( https://docs.axoniq.io/axon-framework-reference/4.10/messaging-concepts/supported-parameters-annotated-handlers/ )
Current Behaviour
This fails with the following exception:
The underlying issues lies by directly instantiating
ClasspathParameterResolverFactory
here:axon-adhoc-projection/extension/core/src/main/kotlin/io/holixon/axon/projection/adhoc/ModelInspector.kt
Line 18 in 1773122
where as for a usage with Spring we would need a
MultiParameterResolverFactory
which is set up with additional Spring specific resolvers (see how Axon does it here)Solution: When running with Spring it should reuse the existing instance of
ParameterResolverFactory
in the application context.Wanted Behaviour
The Spring bean (which is declared and registered in the application context) is resolved and the message handler method called.
Possible Workarounds
Use workaround such as a application context provider to statically gain access the Spring application context and thus retrieving the required beans from the handler method.
The text was updated successfully, but these errors were encountered: