users@glassfish.java.net

Re: Using Hibernate on Glassfish?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Wed, 4 May 2011 13:26:16 -0400

On Wed, May 4, 2011 at 9:11 AM, Sahoo <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.
>

Good to know.

One of Hibernate's "required" dependencies is a jar full of
javax.transaction.* interfaces. It ships with this. I presume I would NOT
include this jar in any of these scenarios, since surely it is already
provided by Glassfish? Or maybe it's OK to pull it in in this manner...?

Additionally, it looks like Hibernate requires antlr-2.7.6.jar, which also
seems to be present in Glassfish.

Now, I just happen to know that, because I did some research. But ideally
I'd like not to care. Sahoo, can you outline or clarify what will happen in
the following case?

   1. I dump *all* of Hibernate's required dependencies into a subdirectory
   in applib named hibernate and construct a nice empty jar file with a
   MANIFEST.MF containing a Class-Path: header that points to (dependent)
   jars in this subdirectory. I name this empty jar hibernate.jar.
   2. I place this hibernate.jar into applib.
   3. I deploy my applications with --library hibernate.jar
   4. Hibernate, when referenced, will use ITS copy of Antlr 2.7.6, and ITS
   copy of jta.jar, and ITS copy of commons-collections-3.1.jar and ITS copy
   of whatever else it ships with rather than those that might happen to be
   loaded by the application server. (True?)

Here are some questions about this scenario I have that I think illustrate
my nervousness.

   - Suppose just for the sake of argument there were a method in some
   Hibernate class that took a javax.transaction.Transaction object and
   performed an instanceof check against its argument.
   - Suppose further that I pass a Transaction object that I received from
   Glassfish.
   - Would this hypothetical instanceof check return true, or false?
   - What would
   Transaction.class.getProtectionDomain().getCodeSource().getLocation()return?
The Hibernate-supplied
   jta.jar's location, or the internal Glassfish JTA jar?


Best,
Laird