Unable to register MBean [HikariDataSource (HikariPool-0)] with key ‘dataSource’

I was having a similar issue, with 2 jhipster application instances running alongside on a single tomcat server.
I posted this also in https://github.com/jhipster/generator-jhipster/issues/874#issuecomment-113023849

From https://docs.oracle.com/javase/tutorial/jmx/mbeans/standard.html

Every JMX MBean must have an object name. The object name is an instance of the JMX class ?ObjectName and must conform to the syntax defined by the JMX specification. Namely, the object name must contain a domain and a list of key-properties.

From http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-jmx

  1. Monitoring and management over JMX
    Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications. By default Spring Boot will create an MBeanServer with bean id ‘mbeanServer’ and expose any of your beans that are annotated with Spring JMX annotations (@ManagedResource, @ManagedAttribute, @ManagedOperation).

See the JmxAutoConfiguration class for more details.

Checking the code of JmxAutoConfiguration in https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java
I saw that there is a spring.jmx.default-domain property that is used in the naming strategy.

Setting that property to some value in one of my apps’ application.properties solved this issue

spring.jmx.default-domain: test

As the domain name is arbitrary, it seems to me like a reasonable way to avoid name clashings between two apps.

Since I had no previous experience with JMX I would appreciate feedback on this solution.

Leave a Comment