users@glassfish.java.net

Re: Using Hibernate on Glassfish?

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Wed, 04 May 2011 18:41:06 +0530

Mitesh's proposal does not require use of Hibernate as a set of OSGi
bundles. Just copy Hibernate and its dependencies to domain/lib and you
should be done. GlassFish's use of SLF4J won't be affected, because
GlassFish neither exposes its SLF4J implementation to user apps nor does
it get affected by user's SLF4J bindings.

If you don't want every application to see every jar that Hobernate
uses, there is a better solution which will allow you to install
multiple versions of Hibernate in GlassFish and yet share it by
different applications. Do the following:

copy hobernate and its dependencies into a directory called
domain1/lib/applib/hibernate-xxx/
create an empty jar in domain1/lib/applib/hibernate-latest.jar with
MANIFEST.MF having Class-Path entry set to all hibernate jars. e.g., it
may look like this:
Class-Path: hibernate-xxx/foo.jar hibernate-xxx/bar.jar ...

 From each that uses this version of hibernate, specify --library
hibernate-xxx.jar while deploying.

Thanks,
Sahoo

On Wednesday 04 May 2011 06:22 PM, Laird Nelson wrote:
> On Wed, May 4, 2011 at 1:55 AM, Richard Kolb <rjdkolb_at_gmail.com
> <mailto:rjdkolb_at_gmail.com>> wrote:
>
> Yes, if you install Hibernate as a OSGi module.
>
>
> (That's kind of what I figured; I don't think Mitesh's solution could
> work unless Hibernate is explicilty packaged as an OSGI module.)
>
> I think Laird's original question said the Hibernate in the update
> center was really out of date. i.e. Not even JPA2. So he is
> looking for a way to install.
>
>
> That's right; the Update Center version is 3.5.0-Final, which violates
> JPA 2.0 JPQL syntax rules (among many other problems). It's worth
> noting that this officially installed update center package pretty
> much just dumps Hibernate in the lib directory. :-)
>
> Best,
> Laird