infinispan as second level cache hibernate

泪湿孤枕 提交于 2019-12-10 16:39:58

问题


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


回答1:


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

The error message should be updated.




回答2:


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


来源:https://stackoverflow.com/questions/37311484/infinispan-as-second-level-cache-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!