users@glassfish.java.net

Updating support for Hibernate on Glassfish: need community's help

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Wed, 10 Aug 2011 10:10:05 -0400

Hello; I'm trying to update the Glassfish Hibernate provider from its
current 3.5.0 version to 3.6.6.Final.

I need the community's help (and that of the Glassfish developers).

The background: if you search on integrating Hibernate with Glassfish, you
will get dozens and dozens of articles that all recommend doing one of these
things:

   - Put Hibernate and its dependencies straight in domain1/lib.
   - Package Hibernate with your application.
   - Install Hibernate from the Update Center.

Each option as currently manifested has problems, ranging from bugs to
classloader problems, or, in the case of the Update Center, version
staleness (Hibernate 3.5.0.Final, the version of Hibernate installed by the
Update Center, violates the JPA 2.0 JPQL syntax and hence is not JPA 2.0
compatible). The state can be best summed up with this well-intentioned
article: http://eskatos.wordpress.com/2007/10/09/hello-world/ The article
itself no longer works, and the update to the article doesn't work either.

Sahoo suggested another approach that I like very much:
http://www.java.net/forum/topic/glassfish/glassfish/using-hibernate-glassfish#comment-814634

This would place the Hibernate dependencies in their own folder under
domain1/applibs, referenced by an empty hibernate.jar with a Class-Path: in
its MANIFEST.MF. This is great. It's isolated, simple to upgrade,
compatible with the IPS packaging mechanism, and applications have to
specify on deployment with the --libraries option that they want Hibernate
to be visible.

So, then. What goes in that dependencies directory?

In the current Hibernate Update Center package, the dependencies are
minimal. You can see what they are by downloading
http://maven.glassfish.org/index.html#view-repositories;Java.net.2~browsestorage~/org/glassfish-repo/packager/hibernate-ips/3.5.0-Final-1/hibernate-ips-3.5.0-Final-1.zipwhenever
http://maven.glassfish.org is not busy with its usual business function of
throwing 503 errors.

The reason they're minimal is that the Hibernate artifact that is installed
is hibernate3.jar, which seems to be a throw-everything-into-the-punch-bowl
distribution of Hibernate. This fellow has a nice summary:
http://www.javaworld.com/community/node/7686

In Hibernate version 3.6.6, thankfully, this artifact is no longer produced
or uploaded to Maven. Instead, it is expected that you will choose your own
dependencies.

That's fine for an individual developer, but when you're talking about
providing support at the application server level, what to do? And that's
where I need your help.

From looking at hibernate-all assembly descriptor (
https://github.com/hibernate/hibernate-core/blob/3.6/hibernate-distribution/src/assembly/hibernate-all.xml),
you can see that the fine folks at Hibernate have replaced
hibernate3.jarwith this recipe. You can further see that the artifact
produced by this
descriptor is going to have every single hibernate-* module in it.

If I were shooting for a simple upgrade of the existing Hibernate Update
Center package, I would probably do what I could to include this, since it's
roughly equivalent to the old hibernate3.jar. But I thought I'd ask here
first, since the hibernate3.jar is kind of an abomination. What
dependencies--and there are many optional ones, cache providers and the
like--should Hibernate Update Center support "ship" with?

As a kind of comparison, you can see that JBoss AS7 ships with a tiny, tiny
amount: https://github.com/jbossas/jboss-as/blob/master/pom.xml#L2696 They
do not seem to include the EHCache, SwarmCache or OSCache providers, for
example.

So, again, besides hibernate-core and hibernate-entitymanager (which
obviously have to exist in order to have Hibernate work at all), what other
dependencies should the Hibernate Update Center package include?

Thanks,
Laird