Exposing Hibernate (cache) statistics through JMX with Spring in Tomcat?

I've recently built a sample Spring based webapp that very cleanly enables JMX for latest versions of Spring, bernate and Ehcache.

I've recently built a sample Spring based webapp that very cleanly enables JMX for latest versions of Spring, It has examples for both EntityManager based access and DAO access (including transactions! ). It also shows how to do annotation based injection in order to negate having to use Spring's xml config for beans.

There is even a SpringMVC based example servlet using annotations. Basically, this is a Spring based version of a fairly powerful application server running on top of any servlet engine. It isn't documented yet, but I'll get to that soon.

Take a look at the configuration files and source code and it should be pretty clear. The motivation behind this is that I got tired of all of the crazy blog posts with 50 different ways to set things up and finally made a single simple source that people can work from. It is up on github so feel free to fork the project and do whatever you want with it.

Https://github. Com/lookfirst/fallback.

1 for bothering to upload nearly 60 third party libs to github, what a waste of resources. Downside of Ant vs. Maven build...Checked your applicationContext. Xml but failed to see how its content is relevant to this question?

– Marcel May 21 at 7:59 1 Waste of resources? Are you really that concerned with a few bits on someone else's disk? As for my applicationContext.

Xml, you are looking in the wrong place. Github. Com/lookfirst/fallback/blob/master/src/java/com/github/… – Jon Stevens May 23 at 0:39 @Marcel how does uploading third party libs to his github account affect the quality of this answer?

I would I could downvote a comment. – matt be Jul 15 at 15:12 @matt b, it doesn't. I only just realized that my comment is missing a few words.

What I meant to say was "Thanks for the answer but -1...". I didn't actually downvote Jon's answer. – Marcel Jul 18 at 18:57 1 Thank you for the nice template.

– Dominik Aug 3 at 8:47.

The JPA EntityManager exposes the underlying so you can get at its Factory: public static Session getbernateSession(EntityManager entityManager) { Session session; if (entityManager.getDelegate() instanceof EntityManagerImpl) { EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate(); session = entityManagerImpl.getSession(); } else { session = (Session) entityManager.getDelegate(); } return session; } You can then use this Session to enable the statistics like we have done it in RHQ project.

Yes, I could do that. Ideally, however, it should be done declaratively. – Marcel May 12 at 22:04.

Spring exposes on JMX only his beans but you can programaticaly export a resource via the MBeanExporter.

Yes, I know that but I try to avoid adding custom code just for that. – Marcel May 9 at 20:07 Your hibernate SessionFactory is a Spring bean? – Treydone May 10 at 12:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions