Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-cloud-starter-bus-amqp conflicts with SpringApplicationAdminJmxAutoConfiguration #62

Closed
kdvolder opened this issue Jul 5, 2016 · 6 comments

Comments

@kdvolder
Copy link

kdvolder commented Jul 5, 2016

I created a project with spring-initializr and added just a single starter.

This added this:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Brixton.SR2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

and this:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amqp</artifactId>
    </dependency>

to my pom (I'll attach full pom as well later).

I guess that seems okay and as expected.

When I run this empty app however it crashes with some nasty error about failing to create JMX releated bean.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.jmx.export.MBeanExporter org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration.mbeanExporter; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.jmx.export.MBeanExporter] is defined: more than one 'primary' bean found among candidates: [mbeanExporter, integrationMbeanExporter, endpointMBeanExporter]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]
    at com.example.DemoBusApplication.main(DemoBusApplication.java:18) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.jmx.export.MBeanExporter org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration.mbeanExporter; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.jmx.export.MBeanExporter] is defined: more than one 'primary' bean found among candidates: [mbeanExporter, integrationMbeanExporter, endpointMBeanExporter]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    ... 17 common frames omitted
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.jmx.export.MBeanExporter] is defined: more than one 'primary' bean found among candidates: [mbeanExporter, integrationMbeanExporter, endpointMBeanExporter]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.determinePrimaryCandidate(DefaultListableBeanFactory.java:1255) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.determineAutowireCandidate(DefaultListableBeanFactory.java:1216) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1124) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    ... 19 common frames omitted

I was expecting the empty app to not do anything, or, perhaps crash with some error for not being able to connect to rabbitmq unsintance until I install and configure it somehow. I was not expecting a problem with JMX beans.

Not sure who this error should be blamed on. Is it initializer not generating proper pom? Is it the spring-cloud-starter-bus-amqp? Something else?

I just made my best guess and raised this against 'spring-cloud-starters' as I don't get this with other starters so I'm inclined to blame the starter for this.

@kdvolder
Copy link
Author

kdvolder commented Jul 5, 2016

This is the full contents of the pom.xml as generated by initializr app.

https://gist.github.com/kdvolder/55e0f196f5db378cb43c698300022714

@kdvolder
Copy link
Author

kdvolder commented Jul 5, 2016

This appears to be some kind of conflict with the SpringApplicationAdminJmxAutoConfiguration stuff which is enabled when running applications from STS using spring-boot-dahsboard. STS turns on this functionality when launching a boot app by default. It is needed to manage the boot apps lifecycle (so IDE can request app to do a clean shutdown), discover info about running app (such as the port a webby app is running on).

When I disable these JMX related features in STS then the error goes away. (This however results in some loss of functionality in STS boot dashboard).

Any idea on how the spring-boot life-cycle management MBeans can be made to play nicely together with spring-cloud-starter-bus-amqp?

@spencergibb
Copy link
Member

You'd have to get in touch with the STS and/or Spring Boot team. My guess is that you'd have the problem even without amqp if you had a plain integration app.

@kdvolder
Copy link
Author

kdvolder commented Jul 5, 2016

Thanks, but I'm actually on the STS team :-)

We need that 'admin' JMX bean which spring-boot provides. I'm trying to figure out who/why these other beans are getting turned on and who to talk to about figuriing out some kind of a solution to this conflict (other than just disabling a bunch of STS functionality to avoid it).

But I guess this problem isn't from the starter itselff but one part of spring-boot conflicting with another part of spring-boot (i.e. not a spring-cloud-specific problem)?

@kdvolder kdvolder changed the title spring-cloud-starter-bus-amqp is broken? spring-cloud-starter-bus-amqp conflicts with SpringApplicationAdminJmxAutoConfiguration Jul 5, 2016
@spencergibb
Copy link
Member

Sorry for not recognizing you Kris. I didn't get your previous message when I had written mine. The bus pulls in spring-cloud-starter-stream-rabbit and spring-cloud-stream and spring-integration-core. We don't do anything specific with jmx. I guess I'm not sure what to do, though I'm not the expert. @dsyer might have a better idea.

@artembilan
Copy link

Closed in favor of spring-projects/spring-boot#6328.

Thank you for spotting such a nasty regression. The only problem was that we don't have enough test coverage. But will we have it anyway ever?.. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants