web-dev-qa-db-fra.com

Impossible d'enregistrer le MBean [HikariDataSource (HikariPool-0)] avec la clé 'dataSource'

Je reçois une erreur inférieure en mode prod pour la combinaison (Java8 + Oauth2 + MySql + Hazelcast + pas de sessions http en cluster). Le mode Dev a bien fonctionné.

Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSou
rce'; nested exception is javax.management.InstanceAlreadyExistsException: com.z
axxer.hikari:name=dataSource,type=HikariDataSource

Dans le journal, la première partie de la création de la source de données (Hazelcast) indique le mode [dev]. Pas sûr que ce soit délibéré.

Veuillez m'aider à résoudre le problème.

journal

Dec 12, 2014 2:44:11 PM org.Apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive D:\tools\Apache-Tomcat-7.0.55\webapps\re
tailenergy.war
[INFO] com.fg.re.ApplicationWebXml - Running with Spring profile(s) : prod
2014-12-12 14:44:19.125  WARN 1368 --- [ost-startStop-1] o.s.b.l.LoggingApplicat
ionListener       : Logging environment value '-Djava.util.logging.config.file="
D:\tools\Apache-Tomcat-7.0.55\conf\logging.properties"' cannot be opened and wil
l be ignored (using default location instead)
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.Apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
[DEBUG] com.fg.re.config.AsyncConfiguration - Creating Async Task Executor
[DEBUG] com.fg.re.config.MetricsConfiguration - Registering JVM gauges
[INFO] com.fg.re.config.MetricsConfiguration - Initializing Metrics JMX reportin
g
[INFO] com.hazelcast.instance.DefaultAddressPicker - null [dev] [3.2.5] Prefer I
Pv4 stack is true.
[INFO] com.hazelcast.instance.DefaultAddressPicker - null [dev] [3.2.5] Picked A
ddress[192.168.1.9]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localp
ort=5701], bind any local is true
[INFO] com.hazelcast.system - [192.168.1.9]:5701 [dev] [3.2.5] Hazelcast 3.2.5 (
20140814) starting at Address[192.168.1.9]:5701
[INFO] com.hazelcast.system - [192.168.1.9]:5701 [dev] [3.2.5] Copyright (C) 200
8-2014 Hazelcast.com
[INFO] com.hazelcast.instance.Node - [192.168.1.9]:5701 [dev] [3.2.5] Creating M
ulticastJoiner
[INFO] com.hazelcast.core.LifecycleService - [192.168.1.9]:5701 [dev] [3.2.5] Ad
dress[192.168.1.9]:5701 is STARTING
[INFO] com.hazelcast.cluster.MulticastJoiner - [192.168.1.9]:5701 [dev] [3.2.5]



Members [1] {
        Member [192.168.1.9]:5701 this
}

[INFO] com.hazelcast.core.LifecycleService - [192.168.1.9]:5701 [dev] [3.2.5] Ad
dress[192.168.1.9]:5701 is STARTED
[DEBUG] com.fg.re.config.CacheConfiguration - Starting HazelcastCacheManager
[INFO] com.hazelcast.util.HealthMonitor - [192.168.1.9]:5701 [dev] [3.2.5] memor
y.used=242.6M, memory.free=219.4M, memory.total=462.0M, memory.max=891.0M, memor
y.used/total=52.51%, memory.used/max=27.23%, load.process=-100.00%, load.system=
100.00%, load.systemAverage=-100.00%, thread.count=38, thread.peakCount=38, even
t.q.size=0, executor.q.async.size=0, executor.q.client.size=0, executor.q.operat
ion.size=0, executor.q.query.size=0, executor.q.scheduled.size=0, executor.q.io.
size=0, executor.q.system.size=0, executor.q.operation.size=0, executor.q.priori
tyOperation.size=0, executor.q.response.size=0, operations.remote.size=0, operat
ions.running.size=0, proxy.count=0, clientEndpoint.count=0, connection.active.co
unt=0, connection.count=0
[DEBUG] com.fg.re.config.DatabaseConfiguration - Configuring Datasource
[DEBUG] com.zaxxer.hikari.HikariConfig - HikariCP pool HikariPool-0 configuratio
n:
[DEBUG] com.zaxxer.hikari.HikariConfig - autoCommit......................true
[DEBUG] com.zaxxer.hikari.HikariConfig - catalog.........................
[DEBUG] com.zaxxer.hikari.HikariConfig - connectionCustomizer............com.zax
xer.hikari.HikariConfig$1@5a3cdbda
[DEBUG] com.zaxxer.hikari.HikariConfig - connectionCustomizerClassName...
[DEBUG] com.zaxxer.hikari.HikariConfig - connectionInitSql...............
[DEBUG] com.zaxxer.hikari.HikariConfig - connectionTestQuery.............
[DEBUG] com.zaxxer.hikari.HikariConfig - connectionTimeout...............30000
[DEBUG] com.zaxxer.hikari.HikariConfig - dataSource......................
[DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceClassName.............com.mys
ql.jdbc.jdbc2.optional.MysqlDataSource
[DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................
[DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceProperties............{user=r
oot, url=jdbc:mysql://localhost:3306/retailenergy, password=<masked>, prepStmtCa
cheSqlLimit=2048, cachePrepStmts=true, useServerPrepStmts=true, prepStmtCacheSiz
e=250}
[DEBUG] com.zaxxer.hikari.HikariConfig - driverClassName.................
[DEBUG] com.zaxxer.hikari.HikariConfig - idleTimeout.....................600000
[DEBUG] com.zaxxer.hikari.HikariConfig - initializationFailFast..........true
[DEBUG] com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
[DEBUG] com.zaxxer.hikari.HikariConfig - jdbc4ConnectionTest.............false
[DEBUG] com.zaxxer.hikari.HikariConfig - jdbcUrl.........................
[DEBUG] com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........0
[DEBUG] com.zaxxer.hikari.HikariConfig - maxLifetime.....................1800000

[DEBUG] com.zaxxer.hikari.HikariConfig - maximumPoolSize.................10
[DEBUG] com.zaxxer.hikari.HikariConfig - metricRegistry..................com.cod
ahale.metrics.MetricRegistry@4152b59f
[DEBUG] com.zaxxer.hikari.HikariConfig - minimumIdle.....................10
[DEBUG] com.zaxxer.hikari.HikariConfig - password........................<masked
>
[DEBUG] com.zaxxer.hikari.HikariConfig - poolName........................HikariP
ool-0
[DEBUG] com.zaxxer.hikari.HikariConfig - readOnly........................false
[DEBUG] com.zaxxer.hikari.HikariConfig - registerMbeans..................false
[DEBUG] com.zaxxer.hikari.HikariConfig - threadFactory...................
[DEBUG] com.zaxxer.hikari.HikariConfig - transactionIsolation............
[DEBUG] com.zaxxer.hikari.HikariConfig - username........................
[INFO] com.zaxxer.hikari.HikariDataSource - HikariCP pool HikariPool-0 is starti
ng.
[DEBUG] com.fg.re.config.DatabaseConfiguration - Configuring Liquibase
[INFO] com.fg.re.config.hazelcast.HazelcastCacheRegionFactory - Starting up Haze
lcastCacheRegionFactory
[DEBUG] com.fg.re.config.MailConfiguration - Configuring mail server
[INFO] com.fg.re.config.WebConfigurer - Web application configuration, using pro
files: [prod]
[DEBUG] com.fg.re.config.WebConfigurer - Initializing Metrics registries
[DEBUG] com.fg.re.config.WebConfigurer - Registering Metrics Filter
[DEBUG] com.fg.re.config.WebConfigurer - Registering Metrics Servlet
[DEBUG] com.fg.re.config.WebConfigurer - Registering Caching HTTP Headers Filter

[DEBUG] com.fg.re.config.WebConfigurer - Registering static resources production
 Filter
[DEBUG] com.fg.re.config.WebConfigurer - Registering GZip Filter
[INFO] com.fg.re.config.WebConfigurer - Web application fully configured
[INFO] com.fg.re.Application - Running with Spring profile(s) : [prod]
[INFO] com.fg.re.config.ThymeleafConfiguration - loading non-reloadable mail mes
sages resources
[WARN] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebAppl
icationContext - Exception encountered during context initialization - cancellin
g refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'mbeanExporter' defined in class path resource [org/springframework/conte
xt/annotation/MBeanExportConfiguration.class]: Invocation of init method failed;
 nested exception is org.springframework.jmx.export.UnableToRegisterMBeanExcepti
on: Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSou
rce'; nested exception is javax.management.InstanceAlreadyExistsException: com.z
axxer.hikari:name=dataSource,type=HikariDataSource
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1554) ~[spring-be
ans-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:539) ~[spring-beans
-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.Java:475) ~[spring-beans-4
.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.Java:302) ~[spring-beans-4.0.8.RELEASE.jar:4.0.8.RELEAS
E]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.Java:228) ~[spring-beans-4.0.8.RELEA
SE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.Java:298) ~[spring-beans-4.0.8.RELEASE.jar:4.0.8.RELEASE]

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.Java:193) ~[spring-beans-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.Java:706) ~[spring-beans-4.0
.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.Java:762) ~[spring-context-
4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.Java:482) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.
RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.refresh(EmbeddedWebApplicationContext.Java:109) [spring-boot-1.1.9.RELEASE.ja
r:1.1.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.
Java:691) [spring-boot-1.1.9.RELEASE.jar:1.1.9.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.Java
:320) [spring-boot-1.1.9.RELEASE.jar:1.1.9.RELEASE]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringA
pplicationBuilder.Java:142) [spring-boot-1.1.9.RELEASE.jar:1.1.9.RELEASE]
        at org.springframework.boot.context.web.SpringBootServletInitializer.cre
ateRootApplicationContext(SpringBootServletInitializer.Java:89) [spring-boot-1.1
.9.RELEASE.jar:1.1.9.RELEASE]
        at org.springframework.boot.context.web.SpringBootServletInitializer.onS
tartup(SpringBootServletInitializer.Java:51) [spring-boot-1.1.9.RELEASE.jar:1.1.
9.RELEASE]
        at org.springframework.web.SpringServletContainerInitializer.onStartup(S
pringServletContainerInitializer.Java:175) [spring-web-4.0.8.RELEASE.jar:4.0.8.R
ELEASE]
        at org.Apache.catalina.core.StandardContext.startInternal(StandardContex
t.Java:5479) [catalina.jar:7.0.55]
        at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
[catalina.jar:7.0.55]
        at org.Apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.Java:901) [catalina.jar:7.0.55]
        at org.Apache.catalina.core.ContainerBase.addChild(ContainerBase.Java:87
7) [catalina.jar:7.0.55]
        at org.Apache.catalina.core.StandardHost.addChild(StandardHost.Java:649)
 [catalina.jar:7.0.55]
        at org.Apache.catalina.startup.HostConfig.deployWAR(HostConfig.Java:1083
) [catalina.jar:7.0.55]
        at org.Apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.Java:
1880) [catalina.jar:7.0.55]
        at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:51
1) [na:1.8.0_25]
        at Java.util.concurrent.FutureTask.run(FutureTask.Java:266) [na:1.8.0_25
]
        at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
Java:1142) [na:1.8.0_25]
        at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.Java:617) [na:1.8.0_25]
        at Java.lang.Thread.run(Thread.Java:745) [na:1.8.0_25]
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable
 to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSource'; nest
ed exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hika
ri:name=dataSource,type=HikariDataSource
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstan
ce(MBeanExporter.Java:608) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExpor
ter.Java:533) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBean
Exporter.Java:415) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.Java:1613) ~[spring
-beans-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1550) ~[spring-be
ans-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        ... 28 common frames omitted
Caused by: javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:na
me=dataSource,type=HikariDataSource
        at com.Sun.jmx.mbeanserver.Repository.addMBean(Repository.Java:437) ~[na
:1.8.0_25]
        at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRep
ository(DefaultMBeanServerInterceptor.Java:1898) ~[na:1.8.0_25]
        at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamic
MBean(DefaultMBeanServerInterceptor.Java:966) ~[na:1.8.0_25]
        at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(
DefaultMBeanServerInterceptor.Java:900) ~[na:1.8.0_25]
        at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(D
efaultMBeanServerInterceptor.Java:324) ~[na:1.8.0_25]
        at com.Sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.j
ava:522) ~[na:1.8.0_25]
        at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(M
BeanRegistrationSupport.Java:195) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEA
SE]
        at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBe
anExporter.Java:653) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstan
ce(MBeanExporter.Java:598) ~[spring-context-4.0.8.RELEASE.jar:4.0.8.RELEASE]
        ... 32 common frames omitted
[INFO] com.fg.re.config.hazelcast.HazelcastCacheRegionFactory - Shutting down Ha
zelcastCacheRegionFactory
[INFO] com.zaxxer.hikari.pool.HikariPool - HikariCP pool HikariPool-0 is shuttin
g down.
[DEBUG] com.zaxxer.hikari.pool.HikariPool - Before shutdown pool stats HikariPoo
l-0 (total=10, inUse=3, avail=7, waiting=0)
[DEBUG] com.zaxxer.hikari.pool.HikariPool - After shutdown pool stats HikariPool
-0 (total=0, inUse=0, avail=0, waiting=0)
[INFO] com.fg.re.config.CacheConfiguration - Remove Cache Manager metrics
[INFO] com.fg.re.config.CacheConfiguration - Closing Cache Manager
[INFO] com.hazelcast.core.LifecycleService - [192.168.1.9]:5701 [dev] [3.2.5] Ad
dress[192.168.1.9]:5701 is SHUTTING_DOWN
[INFO] com.hazelcast.initializer - [192.168.1.9]:5701 [dev] [3.2.5] Destroying n
ode initializer.
[INFO] com.hazelcast.instance.Node - [192.168.1.9]:5701 [dev] [3.2.5] Hazelcast
Shutdown is completed in 31 ms.
[INFO] com.hazelcast.core.LifecycleService - [192.168.1.9]:5701 [dev] [3.2.5] Ad
dress[192.168.1.9]:5701 is SHUTDOWN
[ERROR] org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'mbeanExporter' defined in class path resource [org/springframework/conte
xt/annotation/MBeanExportConfiguration.class]: Invocation of init method failed;
 nested exception is org.springframework.jmx.export.UnableToRegisterMBeanExcepti
on: Unable to register MBean [HikariDataSource (HikariPool-0)] with key 'dataSou
rce'; nested exception is javax.management.InstanceAlreadyExistsException: com.z
axxer.hikari:name=dataSource,type=HikariDataSource
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1554) ~[spring-be
ans-4.0.8.RELEASE.jar:4.0.8.RELEASE]

Nouvelle observation. Plus tôt, j'avais deux webapps jhipster fonctionnant sur le même Tomcat. La suppression de l'autre a supprimé l'erreur. Puis-je en connaître la raison? En production, il peut y avoir une forte possibilité que deux webapps jhipster s'exécutent sur le même Tomcat.

24
Sudheer

J'avais un problème similaire, avec 2 instances d'application jhipster fonctionnant à côté sur un seul serveur Tomcat. J'ai également posté cela dans https://github.com/jhipster/generator-jhipster/issues/874#issuecomment-113023849

De https://docs.Oracle.com/javase/tutorial/jmx/mbeans/standard.html

Chaque MBM JMX doit avoir un nom d'objet. Le nom d'objet est une instance de la classe JMX? ObjectName et doit être conforme à la syntaxe définie par la spécification JMX. À savoir, le nom de l'objet doit contenir un domaine et une liste de propriétés de clé.

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

  1. La surveillance et la gestion via JMX Java Les extensions de gestion (JMX) fournissent un mécanisme standard pour surveiller et gérer les applications. Par défaut, Spring Boot créera un MBeanServer avec l'ID de bean 'mbeanServer' et exposera l'un de vos beans annotées avec des annotations Spring JMX (@ManagedResource, @ManagedAttribute, @ManagedOperation).

Voir la classe JmxAutoConfiguration pour plus de détails.

Vérification du code de JmxAutoConfiguration dans https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/Java/org/springframework/boot/autoconfigure/ jmx/JmxAutoConfiguration.Java J'ai vu qu'il existe une propriété spring.jmx.default-domain utilisée dans la stratégie de dénomination.

Définir cette propriété sur une valeur dans l'une des applications de mon application.properties a résolu ce problème

spring.jmx.default-domain: test

Le nom de domaine étant arbitraire, il me semble que c'est un moyen raisonnable d'éviter les conflits de noms entre deux applications.

Comme je n'avais aucune expérience avec JMX, j'apprécierais les commentaires sur cette solution.

29
Patricio Marrone

J'ai résolu ce type de problème en définissant une valeur différente de spring.jmx.default-domain propriété pour chaque application Spring sur mon Tomcat comme:

spring.jmx.default-domain=somevalue

dans le fichier application.properties.

20
PowR

Deux choses que j'ai essayées et qui ont fonctionné pour déployer deux applications Hikari dans le même Tomcat sont: Non seulement changer le nom du pool (1), mais aussi changer le nom du bean pour la configuration de DataSource (2).

@Bean(destroyMethod = "shutdown")
public DataSource dataSource2() {

    HikariConfig config = new HikariConfig();
    config.setPoolName("AARSHikaripool-1");

Remarquez que le nom du bean est datasource2 tandis qu'une autre application a une source de données !!

Mise à jour pour JHipster:

Puisqu'il n'y a plus de bean de source de données, dans application.yml ajoutez ce qui suit:

spring:
    jmx:
        default-domain: [application_name]
12
pv1

Ajoutez simplement l'annotation ci-dessous sur votre fichier de configuration

@EnableMBeanExport(registration=RegistrationPolicy.IGNORE_EXISTING)

Cela fonctionnera pour vous.

6
Ravirajsinh Vaghela

Il semble que votre application se redéploie, mais lorsqu'il a déployé le conteneur n'a pas appelé la méthode close() ou shutdown() sur le HikariDataSource. Spring doit avoir une propriété "destroy" (ou quelque chose de similaire) qui peut être définie pour le non-déploiement.

Assurez-vous également que vous utilisez la dernière version de HikariCP (2.2.5) si possible, je crois qu'une ancienne version n'a pas désenregistré correctement les MBeans.

EDIT: si vous avez deux WAR dans le même VM qui ont besoin de HikariCP et que vous souhaitez enregistrer des MBeans, vous devez définir chacun pour utiliser un poolName différent. Je vois il utilise le nom de pool par défaut _ HikariPool-0.

1
brettw

L'approche suivante a fonctionné pour moi, randomise le nom de pool du domaine jmx (spring.jmx.default-domain) (veuillez voir JmxAutoConfiguration ):

@Bean
public DataSource dataSource() throws SQLException {
    HikariDataSource dataSource = new HikariDataSource(this);
    dataSource.setPoolName("dataSource_" + UUID.randomUUID().toString());
    return dataSource;
}

@Bean
@ConditionalOnMissingBean(value = ObjectNamingStrategy.class, search = SearchStrategy.CURRENT)
public ParentAwareNamingStrategy objectNamingStrategy() {
    ParentAwareNamingStrategy namingStrategy = new ParentAwareNamingStrategy(new AnnotationJmxAttributeSource());
    namingStrategy.setDefaultDomain("domain_" + UUID.randomUUID().toString());
    return namingStrategy;
}
1
Marcelo C.