Search code examples
hibernatewildflyinfinispanjcachejava-melody

Missing MBean Type: javax.cache:type=CacheStatistics while using infinispan as 2LC in wildfly


We are using wildfly 18.0.1 as application server. As the hibernate-ehcache module is deprecated we changed to the hibernate-jcache module. Wildfly uses infinispan as jcache implementation by default. We also use java melody to monitor our application. Melody found and displayed the ehcaches statisticts out of the box. But it does not find the infinispan statisticts. The infinispan cache is configured in the standalone.xml:

...
<cache-container name="hibernate" default-cache="entity" module="org.infinispan.hibernate-cache" statistics-enabled="true">
    <local-cache name="timestamps"/>
    <local-cache name="entity" statistics-enabled="true">
        <object-memory size="10000"/>
        <expiration lifespan="300000"/>
    </local-cache>
</cache-container>
...

persistence.xml

<persistence version="2.2"
             xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">

    <persistence-unit name="entityManager">
        <jta-data-source>java:jboss/datasources/...</jta-data-source>
        <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>

            <property name="hibernate.cache.use_second_level_cache" value="true" />
            <property name="hibernate.cache.use_query_cache" value="true" />
            <property name="hibernate.generate_statistics" value="true" />
            <property name="hibernate.cache.infinispan.statistics" value="true" />
        </properties>

    </persistence-unit>

</persistence>

So the statistics is enabled. So following the javadoc of the CacheManager the statistic objects must be registered with an ObjectName that is unique and has the following type and attributes:

Type: javax.cache:type=CacheStatistics

That does not happen. Java melody is looking for these objects and can not find any. So it cannot display any informations regarding the caches.

enter image description here

Screenshot of VisualVM showing the infinispan MBeans.

Just wondering if I oversee something or if this is something that should be handled by wildfly or infinispan? Any help is appreciated. Thanks


Solution

  • If I understand everything correct, wildfly is using infinispan as default 2LC provider not as jcache provider. It uses module 'infinispan-hibernate' and not 'infinispan-jcache'. Thats' why it does not behave like a jcache-provider. It is not used that way. @evernat comment configuring infinispan as jcache-provider leaded me to the solution.