users@glassfish.java.net

Re: Using Hibernate on Glassfish?

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Wed, 04 May 2011 22:25:16 +0530

On Wednesday 04 May 2011 06:49 PM, Laird Nelson wrote:
> On Wed, May 4, 2011 at 9:11 AM, Sahoo <sanjeeb.sahoo_at_oracle.com
> <mailto:sanjeeb.sahoo_at_oracle.com>> wrote:
>
> 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.
>
>
> OK....
>
> 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/
>
>
> OK
>
> 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 ...
>
>
> OK, so the applib directory contains a jar named hibernate-latest.jar;
> got that--this jar acts sort of like a symlink using the usual
> MANIFEST.MF Class-Path tricks; got it. (But why do you suggest making
> this jar if we're going to specify a library reference on the command
> line?)
>
> From each that uses this version of hibernate, specify --library
> hibernate-xxx.jar while deploying.
>
>
> So you can specify a library in a directory /underneath/ the applib
> directory? Or did you mean:
>
> --library hibernate-xxx
>
> ...or perhaps:
>
> --library hibernate-xxx/hibernate3.jar
>
> ...? I think maybe you made a typo?
No, I didn't make a typo. You can't specify --library a-directory-name.
It can only be a jar either relative to applib directory or a full path,
which is pretty difficult to maintain across a cluster. When you have
multiple interdependent jars as in the case of hibernate, not each jar
is a library; the library is actually a collection of jars. In such a
case, the technique I suggested where in you can created a proxy jar to
represent a collection of jars makes sense.

Sahoo