[13:26:44 WARN] [org.axonframework.config.DefaultConfigurer]: One of the start handlers in phase [-2147483648] failed with the following exception:
2025-03-22 14:26:44 java.util.concurrent.ExecutionException: org.axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolve parameter 0 (AgentCreatedEvent) in handler public void a.b.c.listener.AgentListener.on(a.b.c.messages.events.agents.AgentCreatedEvent)
I have the following setup:
A Spring Boot instance that publishes events and holds the Aggregates
A non-spring-boot app that uses Kafka and PostgreSQL instead of the AxonServer
When I tried running my non-spring app with AxonServer the same error occured. The `a.b.c.messages` package is shared between the spring and non-spring app.
The spring-boot app is unaffected and works flawlessly. But the non-spring app fails at startup.
I'm using this to register my EventHandler:
@Override
public void registerEventHandler(Object eventHandler) {
configurer.registerEventHandler(conf -> eventHandler);
}
And after that I start the application, once all my EventHandlers are registered. I'm using the DefaultConfigurer
with the JacksonSerializer provided everywhere
I tried looking into the documentation and searching for similar issues but the ones I found seemed to have been left unanswered and I couldn't find more information to my issue in the documentation.
The only thing I found, is https://docs.axoniq.io/axon-framework-reference/4.11/messaging-concepts/supported-parameters-annotated-handlers/ which I follow:
import a.b.c.messages.events.agents.AgentCreatedEvent
...
@EventHandler
public void on(AgentCreatedEvent event) {
agentService.addAgent(event.getAgent());
}
I'd appreciate help on finding out why this error occurs on startup and what causes it so that I can run Axon normally again
The Axon Framework 4 Configuration API, although useable outside of Spring contexts, isn't ideal. This is, in part, why we're doing a massive rewrite of the Configuration API for Axon Framework 5. However, that's not helping you at the moment, @ChronisZero.
Although I need to guess why this is happening, I think it has to do with Axon Framework's lifecycle management. The Configurer
is a place where components, and lifecycle handlers are registered to.
If you have started (through Configurer#start
) the configure and after that try to register event handlers, you've already opened up the buses to interact with your application.
Hence, if this non-Spring application has Kafka as a message source, you start the Configurer
, and only after that register the event handler, the message source will already try to find handlers for the given event.
Now, to circle back, I am not 100% sure whether this is the case, as you haven't shared how you are configuring the rest of your Axon Framework application. Thus, if my assumption is incorrect, I would recommend that you update your question with more information on how you're using Axon Framework's Configuration API at the moment.