[infinispan-issues] [JBoss JIRA] (ISPN-10111) Avoiding Duplicate MBean Registration with Spring
Donald Naro (Jira)
issues at jboss.org
Wed Apr 3 09:46:10 EDT 2019
Donald Naro created ISPN-10111:
----------------------------------
Summary: Avoiding Duplicate MBean Registration with Spring
Key: ISPN-10111
URL: https://issues.jboss.org/browse/ISPN-10111
Project: Infinispan
Issue Type: Enhancement
Affects Versions: 10.0.0.Beta4, 9.4.12.Final
Reporter: Donald Naro
Assignee: Donald Naro
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.infinispan.client.hotrod.RemoteCacheManager at 51a06cbe] with key 'remoteCacheManager'; nested exception is javax.management.InstanceAlreadyExistsException: MXBean already registered with name org.infinispan:type=HotRodClient,name=Default
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.jmx.export.MBeanExporter.lambda$registerBeans$2(MBeanExporter.java:551) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at java.util.HashMap.forEach(HashMap.java:1289) ~[na:1.8.0_201]
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:551) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:434) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:863) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at me.ignaciosanchez.hotrodtester.HotrodTesterApplication.main(HotrodTesterApplication.java:10) [classes/:na]
Caused by: javax.management.InstanceAlreadyExistsException: MXBean already registered with name org.infinispan:type=HotRodClient,name=Default
at com.sun.jmx.mbeanserver.MXBeanLookup.addReference(MXBeanLookup.java:151) ~[na:1.8.0_201]
at com.sun.jmx.mbeanserver.MXBeanSupport.register(MXBeanSupport.java:160) ~[na:1.8.0_201]
at com.sun.jmx.mbeanserver.MBeanSupport.preRegister2(MBeanSupport.java:173) ~[na:1.8.0_201]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:930) ~[na:1.8.0_201]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) ~[na:1.8.0_201]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) ~[na:1.8.0_201]
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) ~[na:1.8.0_201]
at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:137) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:671) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
... 14 common frames omitted
We are using a Spring Boot application (with Spring Cache and Spring Session) and maybe this could be the problem. My configuration is:
@Bean
public InfinispanRemoteConfigurer infinispanRemoteConfigurer() {
return () -> new ConfigurationBuilder()
.addServer()
.host(host)
.port(Integer.parseInt(port))
.statistics()
.enable()
.jmxEnable()
.build();
}
And I have also tried with this one:
@Bean
public SpringRemoteCacheManager cacheManager() {
return new SpringRemoteCacheManager(infinispanCacheManager());
}
@Bean
public RemoteCacheManager infinispanCacheManager() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer()
.host(host)
.port(Integer.parseInt(port))
.statistics()
.enable()
.jmxEnable();
return new RemoteCacheManager(builder.build());
}
But both return me the same error.
Disable Spring JMX auto configuration: spring.jmx.enabled=false
https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.html
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the infinispan-issues
mailing list