Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

infinispan as second level cache hibernate

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 :)

like image 561
Farouk Elabady Avatar asked Jan 06 '23 01:01

Farouk Elabady


2 Answers

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

The error message should be updated.

like image 156
Radim Vansa Avatar answered Jan 08 '23 14:01

Radim Vansa


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);
like image 31
broot02 Avatar answered Jan 08 '23 14:01

broot02