I created a simple app based on https://github.com/avthart/spring-boot-axon-sample
config used is exactly this => https://github.com/avthart/spring-boot-axon-sample/blob/master/src/main/java/nl/avthart/todo/app/configuration/AxonConfiguration.java
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/AbstractMessageHandler.java:77
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?
Allard
(Allard)
March 11, 2016, 7:18pm
2
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.
Hey,
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 : https://github.com/runningonfumes/axon_test
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?
Allard
(Allard)
March 17, 2016, 1:02pm
5
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.
Cheers,
Allard
Allard
(Allard)
March 10, 2017, 1:05pm
7
FYI: The issue has been found and fixed and a solution will be part of the next release.