0

I am getting this Exception when trying to restart CacheManager, that failed to start.

Caused by: org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="DefaultCacheManager" already registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element at org.infinispan.jmx.JmxUtil.buildJmxDomain(JmxUtil.java:53)

I think it's a bug, but am I correct?

The version used is 9.0.0.Final.

EDIT

The error can be seen using this code snippet.

import org.infinispan.configuration.cache.*;
import org.infinispan.configuration.global.*;
import org.infinispan.manager.*;

class Main {

    public static void main(String[] args) {
        System.out.println("Starting");
        GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
        global.transport()
            .clusterName("discover-service-poc")
            .initialClusterSize(3);

        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.clustering().cacheMode(CacheMode.REPL_SYNC);
        DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build(), false);

        try {
            System.out.println("Starting cacheManger first time.");
            cacheManager.start();
        } catch (Exception e) {
            e.printStackTrace();
            cacheManager.stop();
        }


        try {
            System.out.println("Starting cacheManger second time.");
            System.out.println("startAllowed: " + cacheManager.getStatus().startAllowed());
            cacheManager.start();
            System.out.println("Nothing happening because in failed state");
            System.out.println("startAllowed: " + cacheManager.getStatus().startAllowed());
        } catch (Exception e) {
            e.printStackTrace();
            cacheManager.stop();
        }

        cacheManager = new DefaultCacheManager(global.build(), builder.build(), false);
        cacheManager.start();
    }

}
SlyngDK
  • 21
  • 1
  • 5
  • Hmmm, which environment are you on? DefaultCacheManager removes cache manager jmx beans (see [here](https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/manager/DefaultCacheManager.java#L716) and [here](https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/jmx/CacheManagerJmxRegistration.java#L57)) when it stops. How are you restarting the cache manager? – Galder Zamarreño May 20 '17 at 17:01
  • I have added example pproducing the error. I use 9.0.0.Final from maven. – SlyngDK May 24 '17 at 11:26
  • Ok, that code snippet is a little odd, but it shows that starting the same cache manager twice works fine. Only when you start a brand new cache manager instance, with same configuration, without having stopped the previous one, that you get this issue. – Galder Zamarreño May 31 '17 at 15:53
  • If you really want to restart the cache manager, you call stop() first and then call start(). None of the code above calls stop() unless there's an exception, and the code, as is, assuming no other issues, won't call stop() on the cache manager. – Galder Zamarreño May 31 '17 at 15:54

0 Answers0