Axon Configuration problem (without spring)

Hello, I’m trying to implement Axon Configuration (because I can’t use Spring in my case). And whenever I trie to run the application I get this error: Unable to resolve parameter 0 (MyEvent) in handler,
it is the MyEvent (or MyCommand) that are not resolved but still don’t know why.
this is my simple configuration :

Configurer conf = DefaultConfigurer.defaultConfiguration()
        Configuration configuration = conf.start();

the problem is whith The @EventSourcingHandler or @CommandHandler methods.
I wander if there are some other configurations that should be configured before the Aggregate itself,
should I configure a repository before the aggregate’s configuration for exemple?

this MyAggregate class :

public class MyAggregate {
    private UUID id;
    private String eventType;

    public MyAggregate(){}

    public MyAggregate(com.example.myplugin.command.MyCommand cmd){
        AggregateLifecycle.apply(new MyEvent(cmd.getId(), cmd.getEventType()));

    public void on(com.example.myplugin.event.MyEvent event){ = event.getId();
        this.eventType = event.getEventType();

As a test, I made a basic sample project myself, using and switching the main Spring Boot app to be none-Spring Boot.

To be honest, everything works as expected…
Here’s what I have:

The main class:

package com.example.axon;

import org.axonframework.config.Configuration;
import org.axonframework.config.DefaultConfigurer;
import org.axonframework.eventsourcing.eventstore.inmemory.InMemoryEventStorageEngine;

public class AxonApplication {

	public static void main(String[] args) {
		Configuration config = DefaultConfigurer.defaultConfiguration(false)
											   .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine())

			  .send(new MyCommand("aggregate", "event"))

The aggregate class:

package com.example.axon;

import org.axonframework.commandhandling.CommandHandler;
import org.axonframework.eventsourcing.EventSourcingHandler;
import org.axonframework.modelling.command.AggregateIdentifier;
import org.axonframework.modelling.command.AggregateLifecycle;

public class MyAggregate {

    private String id;
    private String eventType;

    public MyAggregate() {

    public MyAggregate(MyCommand cmd) {
        AggregateLifecycle.apply(new MyEvent(cmd.getId(), cmd.getEventType()));
        System.out.println("Reached commanding");

    public void on(MyEvent event) { = event.getId();
        this.eventType = event.getEventType();
        System.out.println("Reached sourcing");

The command class:

package com.example.axon;

import org.axonframework.modelling.command.TargetAggregateIdentifier;

public class MyCommand {

    private String id;
    private String eventType;

    public MyCommand(String id, String eventType) { = id;
        this.eventType = eventType;

    public String getId() {
        return id;

    public String getEventType() {
        return eventType;

The event class:

package com.example.axon;

public class MyEvent {

    private String id;
    private String eventType;

    public MyEvent(String id, String eventType) { = id;
        this.eventType = eventType;

    public String getId() {
        return id;

    public String getEventType() {
        return eventType;

This configuration runs as expected, using JDK17 and the Axon BOM 4.7.0.
Perhaps you can share a sample project containing your implementation that fails, @AhmedAziz_Elj?

I tried the same implementation as yours, and I still get the same problem, in fact I’m developing a Camunda plugin so it has not a main class …
I modified the configuration into :

this.conf =DefaultConfigurer.defaultConfiguration()
                .registerComponent(MyEvent.class,c-> new MyEvent())
                .registerComponent(MyCommand.class, c-> new MyCommand())

and I added a NoArgsConstructor for both MyEvent and MyCommand classes. Now i succesfully connected to Axon server but I’m getting this error from the axonserver terminal when I tried to send a command :

No Handler for command: com.example.camundaplugin.aggregate.MyCommand

Although I am not familiar with Camunda plugin runtime nor the classpath, I am pretty certain they don’t support the Service Loader mechanism.
Axon Framework internally uses classpath scanning to scan your environment for specific service loader files within the Framework’s project. If a Camunda plugin restricts the classpath, I think we’ve got the culprit.

Note this is a massive hunch! If you could try my code in a non-Camunda plugin environment, you’d get more certainty here, as that’s the outlier compared to other Axon Framework applications.

There are several components of Axon Framework it wires by using this methodology.
Most importantly, the components which allow you to use annotated message handlers and those that enhance the capabilities (e.g., to allow consistent routing or support saga lifecycles).
These are the HandlerDefinition and HandlerEnhancerDefinition.

As stated, I am working on a hunch here since I am by no means versed with Camunda plugins, but perhaps the following addition to your configuration does the trick:

                 .registerHandlerDefinition((config, clazz) -> new AnnotatedMessageHandlingMemberDefinition())
                 .registerHandlerEnhancerDefinition(config -> new MultiHandlerEnhancerDefinition(
                         new SagaMethodMessageHandlerDefinition(),
                         new MethodCommandHandlerInterceptorDefinition(),
                         new MethodCommandHandlerDefinition(),
                         new MethodCommandHandlerDefinition(),
                         new MethodQueryMessageHandlerDefinition(),
                         new ReplayAwareMessageHandlerWrapper(),
                         new DeadlineMethodMessageHandlerDefinition(),
                         new MethodCreationPolicyDefinition(),
                         new MethodCreationPolicyDefinition(),
                         new MessageHandlerInterceptorDefinition(),
                         new EndSagaMessageHandlerDefinition()
                 ))/*rest of your configuration*/;

In the meantime, I know some Axon Framework users that are also avid Camunda users. I’ve dropped a question with them too to check whether my assumption is correct.

I know one thing or two about camunda plugins … what are you trying to achieve?

I tried to change my CommandHandler method like this :

    public void handle(CamundaActionEventCmd cmd) throws Exception{
        AggregateLifecycle.apply(new CamundaActionEvent(cmd.getId(), cmd.getEventType(), cmd.getInitializer(), cmd.getVariables()));

and got this error :

org.axonframework.axonserver.connector.command.AxonServerCommandBus.dispatch There was a problem dispatching a command GenericCommandMessage{payload={com.example.camundaplugin.command.CamundaActionEventCmd@6b1827bd}, metadata={}, messageIdentifier='c8bc4e77-df1a-4ca3-b59b-7ac3df3c00e9', commandName='com.example.camundaplugin.command.CamundaActionEventCmd'}.
        org.axonframework.commandhandling.distributed.CommandDispatchException: The command [com.example.camundaplugin.command.CamundaActionEventCmd] does not contain a routing key.

I tried to change @TargetAggregateIdentifire Annotation with @RoutingKey in the Command class but stiil had the same error
now after trying your solution with the CommandHandler method like this :

//    @CreationPolicy(AggregateCreationPolicy.ALWAYS)
    public CamundaActionAggregate(CamundaActionEventCmd cmd) throws Exception{
        AggregateLifecycle.apply(new CamundaActionEvent(cmd.getId(), cmd.getEventType(), cmd.getInitializer(), cmd.getVariables()));

I got the same error.
Bytheway I got this error every time I run the plugin :

org.axonframework.serialization.xml.XStreamSerializer$ An unsecured XStream instance allowing all types is used. It is strongly recommended to set the security context yourself instead!
        org.axonframework.common.AxonConfigurationException: An unsecured XStream instance allowing all types is used. It is strongly recommended to set the security context yourself instead!

I don’t know if this is what causing the problem even though I emplemented this solution :
I create this class :

public class SecureXStreamSerializer {
    private static XStreamSerializer _instance;

    public static XStreamSerializer get() {
        if (_instance == null) {
            _instance = secureXStreamSerializer();
        return _instance;

    private static XStreamSerializer secureXStreamSerializer() {
        XStream xStream = new XStream();
        xStream.allowTypesByWildcard(new String[]{
        return XStreamSerializer.builder().xStream(xStream).build();

and I tried to add it to my configuration but it didn’t make any change , this is how I aaded it to the config :

      .configureSerializer(configuration -> SecureXStreamSerializer.get())
      .configureMessageSerializer(configuration -> SecureXStreamSerializer.get())
      .configureEventSerializer(configuration -> SecureXStreamSerializer.get())

any idea @Steven_van_Beelen !

Hi @Jan_Galinski , I am trying to intercept actions on camunda and send them to Axon server

We are doing the exact same thing with polyflow, aka camunda-bpm-taskpool. Depending on your concrete use case (processInstance/Variable/task/…) we might already have a solution. Check out: GitHub - holunda-io/camunda-bpm-taskpool: Library for pooling user tasks and process related business objects.

What’s not clear to me @AhmedAziz_Elj is whether my previous suggestion of the HandlerDefinition and HandlerEnhancerDefinition changed anything. Would you mind sharing whether it did?

Routing Key issue

Concerning the routing key exception: once more we got something interesting here.
Let me explain where the message originates, perhaps we can deduce based on that why it’s happening.
Axon Framework uses by default an AnnotationRoutingStrategy to find a field/getter on your command used to consistently route your message.

By default, it assumes the presence of the @RoutingKey annotation, which can be configured to use different annotations too (hence why the strategy is called a AnnotationRoutingStrategy).
Furthermore, the @TargetAggregateIdentifier is meta-annotated with @RoutingKey.
Through that, we very easily ensure commands for a specific aggregate are always routed to the same Axon Framework instance.

Now, as this works based on annotations, there’s a layer of annotation scanning involved.
If you’re curious to the implementation, you can find it here.

In all honesty, to figure out why this default behavior, which mind you works for virtually all applications out of the box, doesn’t for yours. I would need to be able to debug the application to better understand what you’re missing here. Or, what misses when using a Camunda Plugin.

So, if the shared sample from @Jan_Galinski doesn’t help directly, perhaps you can make a reproducible public GitHub repository for us to look at?

Serialization Issue

Do you perhaps have more of a stack trace to share concerning this pointer?
I am pretty confident we cover all spots where a serializer is defined through the Configurer, but we can’t be to sure.

Fact it still may pop us, is that this warning (not error) you’re seeing is required to b kept in Axon Framework, since we used to default the XStreamSerializer for users within the Axon Framework 4 lifecycle.
Removing this behavior would incur a breaking changes for users.
However, it is strongly recommended to switch it. Hence the exception.

So, again, if you could share a full stack trace instead of the last line, that would be helpful.

Hello @Steven_van_Beelen, this is the full stack trace of the Serialization Issue :

AVERTISSEMENT [main] org.axonframework.serialization.xml.XStreamSerializer$ An unsecured XStream instance allowing all types is used. It is strongly recommended to set the security context yourself instead!
        org.axonframework.common.AxonConfigurationException: An unsecured XStream instance allowing all types is used. It is strongly recommended to set the security context yourself instead!
                at org.axonframework.serialization.xml.XStreamSerializer$
                at org.axonframework.axonserver.connector.event.axon.AxonServerEventStore$Builder.<init>(
                at org.axonframework.axonserver.connector.event.axon.AxonServerEventStore.builder(
                at org.axonframework.axonserver.connector.ServerConnectorConfigurerModule.buildEventStore(
                at org.axonframework.config.Component.get(
                at org.axonframework.config.DefaultConfigurer$ConfigurationImpl.getComponent(
                at org.axonframework.config.Configuration.getComponent(
                at org.axonframework.config.Configuration.eventBus(
                at org.axonframework.config.AggregateConfigurer.lambda$new$28(
                at org.axonframework.config.Component.get(
                at org.axonframework.config.AggregateConfigurer.lambda$new$32(
                at org.axonframework.config.Component.get(
                at org.axonframework.config.AggregateConfigurer.lambda$initialize$34(
                at org.axonframework.config.LifecycleOperations.lambda$onStart$0(
                at java.base/$3$1.accept(
                at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(
                at java.base/
                at java.base/
                at java.base/$ReduceOp.evaluateSequential(
                at java.base/
                at java.base/
                at org.axonframework.config.DefaultConfigurer.invokeLifecycleHandlers(
                at org.axonframework.config.DefaultConfigurer.invokeStartHandlers(
                at org.axonframework.config.DefaultConfigurer$ConfigurationImpl.start(
                at org.axonframework.config.Configurer.start(


After trying your previous suggestion of the HandlerDefinition and HandlerEnhancerDefinition I still have this error.

Routing Key Issue

It seems that the routing key problem was caused by a null value of the command id … I set a value for the id but the handler problem remains

So this is a git repository maybe you could take a look at it, thank you.

Thanks for taking the time to share a project.
I was just on the point of asking this again, as none of your issues make particular sense any more :sweat_smile:

Now, with seeing the code, I do think you’ve missed including the Serializer configuration you’ve shared earler. So, be sure to include that again. Furthermore, it seems you are dealing with a Spring Boot application. If that’s intended, you can simplify the Serializer configuration like so:

public Serializer serializer() {
    return /*return you safe XStreamSerializer or JacksonSerializer*/

Secondly, your pom.xml shows something odd: you first exclude the axon-server-connector and then add it as a separate dependency.
Note that when adding axon-server-connector, Axon Framework assume you will use Axon Server.

If you aim to use Axon Server, please remove the dedicated dependency and drop the exclusion on the axon-spring-boot-starter dependency.
If you do not want to use Axon Server, it is a lot easier to set axon.axonserver.enabled=false in your properties file.

First of all, thank you for taking the time to look at the code. Secondly, as I mentioned before, I am not dealing with a Spring Boot application because I am unable to use the @Autowired annotation to create an instance of the CommandGateway interface. Whenever I try to do this, I always get a NullPointerException, therefore, I thought this would explain why I’m not using the spring-autoconfig…

Regarding the Serializer, I have already found a solution. Thank you.

Regarding the AxonServer Connector exclusion, I have mentioned in the pom.xml file in a comment that I excluded version 4.7.1 because I had a problem connecting to the Axon server that’s why I added the 4.0.2 version instead.

Finally, I found a solution to make Axon detect my command, but I’m not sure if it’s a good one. I subscribed the command bus to a message handler by creating a class that implements the MessageHandler<CommandMessage<?>> interface and overrides its handle() method.

Alright, here come a ton of replies coming in, as I have a lot of comments on what you just shared:

If you’re not using Spring Boot, why does your sample use the axon-spring-boot-starter? That’s not the right dependency to ingest if you aim to not use Spring at all.
Furthermore, the repo you’ve shared does not contain any mention of the Configurer from Axon Framework.

Again, if you are not using Spring Boot, you need to use the Configurer.

You should not use the @Autowired annotated to create a CommandGateway implementation but rather to wire it. If you want to create a bean, you need to use the @Bean annotation on a method returning the CommandGateway, or you use @Component (or an annotation meta-annotated with @Component) on a custom CommandGateway implementation.

Regardless of the above, 9 out of 10 cases you do not have to construct a CommandGateway yourself since Axon Framework exposes one on the Configuration#commandGateway method.

If wiring causes a NullPointerException, I’d honestly dive into why Spring fails to wire a bean that for all our users simply works. Perhaps you can share the stack trace on that instead.

Would you mind sharing the solution? The forum is intended to be a back-and-forth where other users can check if they have the same issue. Hence, if you give your solution, others can benefit from that as well.

I strongly recommend against using 4.0.2 of the axonserver-connector module. The recent version of the connector contains many bug fixes, enhanced flexibility, features, and performance enhancements.
If you have a problem connecting with the recent version, you’d have a task of sharing what that problem is, so that we can help with that.

In my honest opinion, moving back to a 4-year-old release is the wrong direction to take in any such scenario.

You can do everything manually like this, sure, but you shouldn’t have to.
If you are not using Spring, it is your task to register classes containing message handlers (so, the annotated methods).

Directly using the CommandBus is one way, but you can let the Framework inspect your class and register any message handlers in there, by using Configurer#registerMessageHandler instead.

If you would go for Spring regardless (since as far as I currently now, that should simply work, also for Camunda plugins), you only need to make the class a part of Spring’s Application Context.

When I said “I’m not using spring boot” I didn’t mean I’m not using it at all, but because I got the NullPointerException when spring fails to wire the CommandGateway, so I tried to find a solution where I can do the configuration manually.

Regarding the Serializer I used a solution that I found in your forum, I can’t find the link, but it is the same as yours

Concerning the axon-server-connector this the stack trace :

io.axoniq.axonserver.connector.impl.AxonServerManagedChannel - Connecting to AxonServer node [localhost:8124] failed.
io.grpc.StatusRuntimeException: UNKNOWN
        at io.grpc.stub.ClientCalls.toStatusRuntimeException(
        at io.grpc.stub.ClientCalls.getUnchecked(
        at io.grpc.stub.ClientCalls.blockingUnaryCall(
        at io.axoniq.axonserver.grpc.control.PlatformServiceGrpc$PlatformServiceBlockingStub.getPlatformServer(
        at io.axoniq.axonserver.connector.impl.AxonServerManagedChannel.connectChannel(
        at io.axoniq.axonserver.connector.impl.AxonServerManagedChannel.createConnection(
        at io.axoniq.axonserver.connector.impl.AxonServerManagedChannel.ensureConnected(
        at io.axoniq.axonserver.connector.impl.AxonServerManagedChannel.getState(
        at io.axoniq.axonserver.connector.impl.ContextConnection.ensureConnected(
        at io.axoniq.axonserver.connector.impl.ContextConnection.connect(
        at io.axoniq.axonserver.connector.AxonServerConnectionFactory.connect(
        at org.axonframework.axonserver.connector.AxonServerConnectionManager.createConnection(
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(
        at org.axonframework.axonserver.connector.AxonServerConnectionManager.getConnection(
        at org.axonframework.axonserver.connector.command.AxonServerCommandBus.subscribe(
        at com.example.axoncamunda.CustomEventType.<init>(
        at com.example.axoncamunda.CustomEventType.<clinit>(
        at com.example.axoncamunda.AxonCamundaPlugin.preInit(
        at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.invokePreInit(
        at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.init(
        at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(
        at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.startService(
        at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.startService(
        at org.camunda.bpm.container.impl.deployment.StartProcessEngineStep.performOperationStep(
        at org.camunda.bpm.container.impl.spi.DeploymentOperation.execute(
        at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.executeDeploymentOperation(
        at org.camunda.bpm.container.impl.spi.DeploymentOperation$DeploymentOperationBuilder.execute(
        at org.camunda.bpm.container.impl.tomcat.TomcatBpmPlatformBootstrap.deployBpmPlatform(
        at org.camunda.bpm.container.impl.tomcat.TomcatBpmPlatformBootstrap.lifecycleEvent(
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(
        at org.apache.catalina.util.LifecycleBase.setStateInternal(
        at org.apache.catalina.util.LifecycleBase.setState(
        at org.apache.catalina.core.StandardServer.startInternal(
        at org.apache.catalina.util.LifecycleBase.start(
        at org.apache.catalina.startup.Catalina.start(
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.base/java.lang.reflect.Method.invoke(
        at org.apache.catalina.startup.Bootstrap.start(
        at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.nio.channels.UnsupportedAddressTypeException: null
        at java.base/
        at java.base/
        at java.base/
        at java.base/
        at io.netty.util.internal.SocketUtils$
        at io.netty.util.internal.SocketUtils$
        at java.base/
        at io.netty.util.internal.SocketUtils.connect(
        at io.grpc.netty.WriteBufferingAndExceptionHandler.connect(
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(
        at io.netty.util.concurrent.SingleThreadEventExecutor$
        at io.netty.util.internal.ThreadExecutorMap$
        at java.base/

Itried many different versions of grpc and netty bytheway and I got the same stack trace everytime.