CreatedEvent handler method not found

I created a simple app based on

config used is exactly this =>

in my controller I create an Account

johnId = UUID.randomUUID().toString();
commandGateway.send(new CreateAccountCommand(johnId, “John”, BigDecimal.TEN));

This works perfectly fine. The AggregateRoot is called, the CreatedEvent applied and even picked up by a listener.

Then I want to activate the account in a next call. So my second controller method contains

commandGateway.send(new ActivateAccountCommand(johnId));

But this does not work. The createdEvent is loaded from the eventstore but cannot be correctly applied on the aggregate.

I trace it down to org/axonframework/common/annotation/

if (payloadType != null && !payloadType.isAssignableFrom(message.getPayloadType())) {

For some reason this returns false

strange thing is that
payloadType = class@6447 class com.thanksys.core.transactionservice.domain.model.valuestore.ValueStoreCreatedEvent

message.getPayloadType()) = class@6041 class com.thanksys.core.transactionservice.domain.model.valuestore.ValueStoreCreatedEvent

Any idea what I’m doing wrong?

Are you sure you don’t have the class on your classpath twice? If two classes with the same name were loaded by different classloaders, they’re not equals (or assignable) etc.


thanks for the tip. I had a look but could not find any issues.

I created a new repo with a minimal example that still has the problem :

If you run gradle bootRun and the go to url localhost:8080/step/1, it will crash because the created event is not applied to the aggregate.

I found the solution. Removing the dependency org.springframework.boot:spring-boot-devtools solved the issue.

Not sure why though. And not sure how to address this. Create a ticket on the devtools bugtracker?

It seems that spring-boot-devtools will automatically reload classes that have changed. This means that you get a new class in the JVM. Axon has already inspected the classes, and keeps a reference to the old class. Since the new class was reloaded, .equals() returns false and the classes aren’t assignable to eachother. That causes the handler to be skipped.

Currently, Axon doesn’t support class reloading this way.



FYI, found the following in the spring devtools documentation.

FYI: The issue has been found and fixed and a solution will be part of the next release.