On Wednesday 04 May 2011 10:56 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.
>
>
> 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...?
GlassFish uses a hierarchical class loader for regular Java EE
applications with some caveats. Even if you include Java EE API classes
in your applications, they won't be picked up from application space.
Instead they will be picked up from glassfish internal jars. So, it does
not matter if you copy javax.transaction.jar into applib or not. If you
search this forum, you will find some postings about our class loader
hierarchy in v3.x series.
>
> Additionally, it looks like Hibernate requires antlr-2.7.6.jar, which
> also seems to be present in Glassfish.
GlassFish bundled antlr is not available to applications. GlassFish uses
OSGi techniques to hide its implementation classes from leaking into
user apps. See
http://java.net/jira/browse/GLASSFISH-5385 for details.
This is not always correctly configured, but I checked it is done
correctly for antlr.
>
> 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?)
>
JTA will be used from GlassFish and that's the desired behavior, else
Hibernate can't communicate with GlassFish TM. ASM, Antlr,
commons-collection will be picked up from applib.
Thanks,
Sahoo