Issues encountered when moving to distributed command bus + '__axon-annotation-command-handler-bean-post-processor'

Hi,
We are in the process of migrating from Simple Command Bus -> Distributed Command Bus. Encountering the following error when we are trying to start our application. Its unable to wire the bean with name ‘__axon-annotation-command-handler-bean-post-processor’.

The detailed stack trace is below:

2019-07-05T11:41:52.006+05:30 [APP/PROC/WEB/0] [OUT] 2019-07-05 06:11:52.005 WARN [*******] 27 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘__axon-annotation-command-handler-bean-post-processor’: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
2019-07-05T11:41:52.027+05:30 [APP/PROC/WEB/0] [OUT] Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2019-07-05T11:41:52.027+05:30 [APP/PROC/WEB/0] [OUT] 2019-07-05 06:11:52.027 INFO [*****] 27 — [ main] ConditionEvaluationReportLoggingListener :
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1471)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1491)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:248)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:174)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:177)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.CachedIntrospectionResults.(CachedIntrospectionResults.java:294)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.CachedIntrospectionResults.buildGenericTypeAwarePropertyDescriptor(CachedIntrospectionResults.java:359)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.GenericTypeAwarePropertyDescriptor.(GenericTypeAwarePropertyDescriptor.java:106)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:61)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.core.ResolvableType.resolveMethodParameter(ResolvableType.java:1297)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.core.ResolvableType.as(ResolvableType.java:443)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.core.ResolvableType.getSuperType(ResolvableType.java:453)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at java.lang.Class.getGenericSuperclass(Class.java:777)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(ParameterizedTypeImpl.java:51)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.reflect.MalformedParameterizedTypeException: null
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at java.lang.reflect.Method.invoke(Method.java:498)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at com.test.ngpp.Application.main(Application.java:33)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:708)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
2019-07-05T11:41:52.036+05:30 [APP/PROC/WEB/0] [OUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)

My axon configuration is given below:

@Bean
public CommandBusConnector springHttpCommandBusConnector(
        @Qualifier("localSegment") CommandBus localSegment,
        @Qualifier("clientCredentialsRestTemplate") RestOperations restOperations,
        Serializer serializer) {
    return SpringHttpCommandBusConnector.builder()
            .localCommandBus(localSegment)
            .restOperations(restOperations)
            .serializer(serializer)
            .build();
}

@Bean
public CommandRouter springCloudCommandRouter(DiscoveryClient discoveryClient) {
    return SpringCloudCommandRouter.builder()
            .discoveryClient(discoveryClient)
            .routingStrategy(new AnnotationRoutingStrategy(STATIC_KEY))
            .localServiceInstance(localServiceInstance)
            .build();
}

@Primary
@Bean
public DistributedCommandBus springCloudDistributedCommandBus(
        CommandRouter commandRouter,
        CommandBusConnector commandBusConnector) {
    return DistributedCommandBus.builder()
            .commandRouter(commandRouter)
            .connector(commandBusConnector)
            .build();
}


Would be thankful if any of you could help us with this? We are using Eureka for service discovery. Please let me know if more details are needed. Axon version used is 4.0. I'd tried upgrading to 4.1.1 but the same issue persists.

Thanks
Anish


Hi Team: Can any of you kindly help?

Thanks
Anish

I’m not sure this is an Axon problem. It seems that Spring is trying to initialize a bean, and fails to do so.
A quick google revealed that this has occurred to many people in the past, and was caused by different spring library versions on the classpath.

Hope this helps.
Cheers,