AggregateMember inheritance: No handler was subscribed to command

I have the below aggregate which contains an aggregate member.

@Aggregate
public class CpaAggregate {

	@AggregateIdentifier
	private String externalId;

	@AggregateMember
	private Entity entity;

	public CpaAggregate() {
	}

	@CommandHandler
	public CpaAggregate(CreateCpaCommand cmd) {
		AggregateLifecycle.apply(new CpaCreatedEvent(...));
	}

	@EventSourcingHandler
	protected void on(CpaCreatedEvent evt) {
	  ....
	}

}

public class Entity {

	@EntityId
	private String entityId;
	
	private Set<Identifier> identifiers = new HashSet<>();

	public Entity() {
	}

	@EventSourcingHandler
	public void on(IdentifiantUpdatedEvent evt) {
		...
	}
	
}

public class Laboratory extends Entity {

	private OperatingSystem operatingSystem;

	public Laboratory() {
	}
	
	@CommandHandler
	public void handle(UpdateIdentifierLABCommand cmd) {
	   AggregateLifecycle.apply(new IdentifiantUpdatedEvent(....));
	}
	
}
commandGateway.sendAndWait(new UpdateIdentifierLABCommand(...));

When i send a command to update an identifier of entity of type laboratory, i get this error

org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed to command [UpdateIdentifierLABCommand]

Hmmm l think I have faced this issue before maybe try adding a type parameter on aggregate member annotation like this.

@AggregateMember(type = Laboratory.class)

Hi @Aymen_Kanzari,

I believe it to be a duplicate of a question posted on stackoverflow and already answered by my colleague @Steven_van_Beelen!

Since I left the link here, I will mark it as resolved but feel free to follow up with additional questions or comments.

KR,

1 Like