My current project uses JBoss (version 4.0.4GA) and Hibernate.Thinking that since Hibernate is developed and maintained by JBoss, we decided to use the proprietary HAR-archive deployment option for our Hibernate configuration (see also this JBoss Wiki page). This uses a custom JMX MBean (org.jboss.hibernate.jmx.Hibernate) that is supposed to wire up all our configuration and make the finished SessionFactory available through JNDI.
We have used this configuration for well over a year now (approaching two years) and haven’t had any major problems with it. (Had to write a custom maven-1 plugin to create an appropriate archive though..) That suddenly changed the other day when we were trying to modify some configuration options for performance reasons, we stumbled into a hornets nest.

We tried to deploy two different Hibernate Archives using ehCache as the second-level cache provider. The first deployed fine, but the second one failed bigtime. Digging through the logs gave us the answer to why: it tries to use the same configuration file (ehcache.xml) as the first one. The fix for this is easy: configure a new file and point a Hibernate property to use this file. That’s when the shock comes to us: The JMX Bean doesn’t allow us to set all hibernate properties.

How shocked do you think I was? You would assume that when JBoss supplies their preferred way to deploy a Hibernate configuration, it would just work. Well let me tell you: it doesn’t!

So far, my search has resultet in me finding several (old) issues in the JBoss-Hibernate JIRA. Many of the common Hibernate configuration options are not configurable through the JMX interface.

Our solution? Download the JBoss source code, expand the JMX interface, build the source and deploy the newly patched jboss-hibernate.jar into our server instance. So for each configuration setting we need to change, we must re-patch our JBoss.
Does it work? Yes, it seems so
Do I like it? Not at all