Ehcache JSR-107, Guice RI and MBean cache statistics...

695 views
Skip to first unread message

Bob Breitling

unread,
Jan 26, 2017, 9:31:46 AM1/26/17
to ehcache-users
I am using Ehcache 3.2.0 and the Guice 4.1.0 RI of JSR-107.
I am using Java 1.8 on Windows 10.

The caching tags (@CacheResult) are working. My app and my JUnit test show this to be true.
In my unit test I can access the default MBean server and get the caching statistics. This all works.
In my application (running with Tomcat 8), I am using the JConsole app from my JDK to examine the MBeans. They are there (I can see javax.cache and my cache manager) and everything looks like it is working, but I do not see any of the statistics (everything is 0) and the operations (clear) are not working.

Does anybody have any insight into this?

My caches are defined with a ehcache.xml file. When my app runs in Tomcat, I can see in my log files the caching getting setup and everything looks good. And! the caches are working. I can tell this from my debugging sessions. JConsole shows my cache manager and all the caches define in my xml configuration file:

ehcache.xml
------------------
<ehcache:config
    xmlns:ehcache="http://www.ehcache.org/v3"
    xmlns:jcache="http://www.ehcache.org/v3/jsr107"
>
    <ehcache:service>
        <jcache:defaults enable-management="true" enable-statistics="true"/>
    </ehcache:service>
   
    <ehcache:cache alias="DragonStandardFields">
        <ehcache:heap unit="entries">1</ehcache:heap>
    </ehcache:cache>

</ehcache:config>
---------------------

just no stats and no operations.

I tried to make sure all my code, etc. matches the Ehcache 3.x JSR-107 Provider documentation.

My unit tests which are working use the same code to define my cache manager and set up my caches and I get statistics (values other than 0).

Any ideas?

TIA,
Bob

Louis Jacomet

unread,
Jan 26, 2017, 11:22:45 AM1/26/17
to ehcache-users
Hi Bob,

That is very strange indeed. The fact that you use the annotations for doing cache interactions should be irrelevant with regards to the stats and MBean operations being available / working.

While we do not have specific tests for the full integration, including interacting with the MBeans from a console, we have a number of tests (including the JCache TCK) that show the bits are working together.

Could you see what happens if you try with Ehcache 3.1.3?
Otherwise, if you are able to create a sample project that reproduces the problem, it would help track down the exact cause.

Regards,
Louis 

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/cc99b3e1-56c9-4c94-bff4-f13ad8eb1f5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Breitling

unread,
Jan 26, 2017, 1:46:07 PM1/26/17
to ehcache-users
Louis,

I switched to Ehcache 3.1.3 and the stats are now showing up in the JConsole.

The clear operation, cleared the stats data. I was thinking it was going to clear the cache. So I have some work to do to clear the cache from the JConsole.

Bob

Louis Jacomet

unread,
Jan 26, 2017, 3:01:44 PM1/26/17
to ehcache-users
Bob,

Thanks for the info.
We will have a look before cutting a 3.2.1 to make sure stats are fully functional.

And indeed, I did not jump on that specific point but the clear on the stats MBean is about clearing stats, not the cache.
There is no support for a clear operation on a cache from JMX in JCache. And Ehcache does not offer a native solution either.
So you will have to roll your own solution there for now.

Regards,
Louis

Henri Tremblay

unread,
Jan 27, 2017, 10:04:53 AM1/27/17
to ehcache-users
Hi Bob,

I am a bit surprised because after digging a bit, there is not much differences between the 2 versions.

When I've encounter your problem, it was generally because the CacheManager exposed in JMX wasn't the one used for caching.

Can you retry 3.2 and make sure only 1 cache manager is used?

Bob Breitling

unread,
Jan 27, 2017, 12:29:12 PM1/27/17
to ehcache-users
Henri,

When I was using 3.2.0, the log entries and the JConsole entries only showed one cache manager and I'm pretty sure they where the same. I was thinking along the same lines, so I believe I verified this was the case. I'll convert back to 3.2.0 when I get a chance and retest things again to make sure that is the case. One interesting point: my unit test cases showed stats and all the same code is used and, I believe, in my test class, the MBean ObjectName matched the cache manager in JConsole. All this is very strange, indeed.

Thanks for the assistance.

Bob
Reply all
Reply to author
Forward
0 new messages