Is it possible to have aggregate member defined as List< someInterface > which have more than one implementation classes?
I have tried it with eventForwardingMode set to instances, new object has been added to the list from the aggregate, but few related commands and events should be handled in the member. But application even dont start - it throws
BeanCreationException (while creating bean …AggregateFactory), caused by NullPointerException at AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.handlers.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cz.aura.lis.asset.operations.purchase.PurchaseOperationAggregateFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at cz.aura.lis.MonoLIS.main(MonoLIS.java:53) ~[classes/:na]
Caused by: java.lang.NullPointerException: null
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.handlers(AnnotatedAggregateMetaModelFactory.java:629) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.commandHandlers(AnnotatedAggregateMetaModelFactory.java:532) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedChildEntity.<init>(AnnotatedChildEntity.java:62) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AbstractChildEntityDefinition.createChildDefinition(AbstractChildEntityDefinition.java:70) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.lambda$createChildDefinitions$14(AnnotatedAggregateMetaModelFactory.java:407) ~[axon-modelling-4.4.7.jar:4.4.7]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.createChildDefinitions(AnnotatedAggregateMetaModelFactory.java:406) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.inspectFieldsAndMethods(AnnotatedAggregateMetaModelFactory.java:370) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.initialize(AnnotatedAggregateMetaModelFactory.java:240) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory$AnnotatedAggregateModel.access$000(AnnotatedAggregateMetaModelFactory.java:207) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory.createModel(AnnotatedAggregateMetaModelFactory.java:201) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.modelling.command.inspection.AnnotatedAggregateMetaModelFactory.inspectAggregate(AnnotatedAggregateMetaModelFactory.java:153) ~[axon-modelling-4.4.7.jar:4.4.7]
at org.axonframework.spring.eventsourcing.SpringPrototypeAggregateFactory.afterPropertiesSet(SpringPrototypeAggregateFactory.java:117) ~[axon-spring-4.4.7.jar:4.4.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 15 common frames omitted
I’d like to notify you @votrluk that we’ve released Axon Framework 4.4.8 today.
This release does not immediately address the usage of an interface on the @AggregateMember.
What it does do, is provide you with a clearer exception than a NullPointerException.
Future work in this area would be conceiving a clean/nice approach that does allow an interface on the @AggregateMember.