4

Trying to use infinispan as a second level cache for hibernate but always gives me the following error

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:51) at org.infinispan.jmx.CacheManagerJmxRegistration.updateDomain(CacheManagerJmxRegistration.java:79)

and here is the hibernate properties

setProperty("hibernate.cache.use_second_level_cache", "true");
            setProperty("hibernate.cache.use_query_cache", "true");
            setProperty("hibernate.cache.region.factory_class",
             "org.hibernate.cache.infinispan.InfinispanRegionFactory");
            setProperty("hibernate.cache.infinispan.statistics", "false");
            setProperty("hibernate.cache.infinispan.cfg", "infinispan-config.xml");

the infinispan config file

<?xml version="1.0" encoding="UTF-8"?>
   <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="urn:infinispan:config:7.2"
    xsi:schemaLocation="urn:infinispan:config:7.2 
                        http://www.infinispan.org/schemas/infinispan-config-7.2.xsd
                       urn:infinispan:config:store:jdbc:7.2
                       http://www.infinispan.org/schemas/infinispan-cachestore-jpa-config-7.2.xsd">

    <cache-container default-cache="default" statistics="false">
    <local-cache name="simpleCache" statistics="false">
    </local-cache>

    </cache-container>
</infinispan>

I have two projects with two datasources , one for audit and the other is the main web project. and the xml value that is in the exception doesn't exist in infinispan version 7.2 onward thanks in advance for any help :)

CMedina
  • 4,034
  • 3
  • 24
  • 39

2 Answers2

8

Add <jmx duplicate-domains="true" /> to <cache-container />.

The error message should be updated.

Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
  • Worked great , many thanks :) , but isn't that just a work around the main problem which is creating the JMX domain multiple times ? – Farouk Elabady May 19 '16 at 09:04
  • 1
    Depends on your setup, and how you use JMX. You can set `` to view them in distinct domains. – Radim Vansa May 19 '16 at 09:42
  • guess I have to dive more inside the infinispan documentation to understand the correct configuration for the JMX , but according to them the defaults should work with no problems :(, but seems that is not the case. – Farouk Elabady May 19 '16 at 11:50
1

As an alternative solution, where you are trying to get rid of xml configuraton files if needed. We can allow duplicate domains programmatically as well.

GlobalConfiguration config = new GlobalConfigurationBuilder()
                                .globalJmxStatistics()
                                .allowDuplicateDomains(Boolean.TRUE)
                                .build();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(config);
broot02
  • 103
  • 1
  • 2
  • 11