Note that there are some explanatory texts on larger screens.

plurals
  1. POExposing Hibernate (cache) statistics through JMX with Spring in Tomcat
    primarykey
    data
    text
    <p>Collecting Hibernate/Ehcache statistics and exposing them through JMX in Spring-based setups seems easy. The Internet has lots of resources that help e.g. <a href="http://snippets.dzone.com/posts/show/11159" rel="nofollow">http://snippets.dzone.com/posts/show/11159</a></p> <p>However, all those articles assume one is working with a Hibernate session factory of some sort. I'm not - my entities are JPA annotated and I use a <code>javax.persistence.EntityManager</code>. If I were deploying to a Java EE container I might have been able to obtain a Hibernate session factory through JNDI as described here <a href="http://internna.blogspot.com/2007/08/hibernate-statistics-in-enterprise-5.html" rel="nofollow">http://internna.blogspot.com/2007/08/hibernate-statistics-in-enterprise-5.html</a> but I'm on Tomcat...</p> <p>How to go about this? I haven't come up with a solution yet.</p> <p>If I had a reference to the Ehcache <code>CacheManager</code> I could try something like:</p> <pre><code>&lt;context:mbean-server /&gt; &lt;bean class="net.sf.ehcache.management.ManagementService" init-method="init"&gt; &lt;constructor-arg ref="..myCacheManager.."/&gt; &lt;constructor-arg ref="mbeanServer"/&gt; &lt;constructor-arg value="true"/&gt; &lt;constructor-arg value="true"/&gt; &lt;constructor-arg value="true"/&gt; &lt;constructor-arg value="true"/&gt; &lt;/bean&gt; </code></pre> <p>Since the cache manager is created by Hibernate (i.e. it's not a Spring bean) it won't work. I tried replacing that ref with </p> <pre><code>&lt;constructor-arg&gt;&lt;bean id="cacheManager" class="net.sf.ehcache.CacheManager" factory-method="getInstance"/&gt;&lt;/constructor-arg&gt; </code></pre> <p>hoping I'd somehow catch the right instance. Won't work either as this would in fact create a new cache manager instance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload