Hi Christopher,
Everything seems to be alright when I check the classes. Is the AddWasteTypeCommandHandler class in the same package (or a sub-package) as the package with the main application class?
That is probably the reason why the command handler is not found. The discovery mechanism to find Spring beans (aggregate annotated classes are spring beans) starts from the package where the Spring application is defined. So, suppose your main class is in package a.b.c. In that case, only beans in the same package or any subpackage are found, not those defined in package a.b.d. If you want to include another package, you can either add a basePackages attribute to the SpringBootApplication annotation or add a ComponentScan annotation.
I was referring to packages below the main application class, in your case this looks like the SpringKotlinRestfulApiSampleApplication class. Can you share the project so I can check?
I found several issues with the project. First it uses the axon-spring module, but the auto registration of Axon annotated aggregates and methods requires the axon-spring-boot-starter module.Using this module, the application will try to use Axon Server as its event store and to distribute commands and queries. If you want to run standalone, you can set the following property in application.properties:
axon.axonserver.enabled=false
Also, the h2 version that you included is too old. If you change it to version 1.4.197 it works better.
Finally, the command handler either needs to be on the constructor or have the annotation @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING) to create an instance of the aggregate. Also, to be able to restore the state of the aggregate, you must set all properties in the aggregate in event sourcing handlers, so instead of setting this.wasteTypeId in the command handler, set it in a method like this:
@EventSourcingHandler
fun on(event: AddWasteTypeEvent) {
this.wasteTypeId = event.wasteTypeId
}