users@glassfish.java.net

Re: OSGi bundle cannot find classes in glassfishv3/glassfish/lib/*.jar files

From: <glassfish_at_javadesktop.org>
Date: Mon, 12 Apr 2010 10:57:11 PDT

My current focus is building a JPA wrapper that allows multiple bundles to register classes to the same persistence unit and have the persistence unit update as bundles are deployed/undeployed.

My approach is as follows:

- I have a bundle that exports my implementation of javax.persistence.spi.PersistenceProvider. My persistence provider also has "holder" objects for EntityManagerFactory and EntityManager which serve as delegates for the actual JPA implementation. It uses ServiceListeners to listen for when our other bundles are deployed/undeployed.

- When a new WebApp Bundle is deployed, it finds the persistence.xml inside the new bundle which lists the managed classes in that bundle, and creates a new EntityManagerFactory, and updates all of my "holder" objects.

- When a WebApp Bundle is undeployed, it unregisters the classes it provided and again the EntityManagerFactory is re-created.

Our applications use JPA for persistence, but we need to do some advanced queries, so we use Hibernate as our JPA provider. I installed Hibernate JPA from the Glassfish Update Tool (which is really nice btw), which put the jars in glassfishv3/glassfish/lib. When my persistence bundle tries to instantiate the Hibernate JPA provider (HibernatePersistence), I get a ClassNotFoundException for org.hibernate.ejb.HibernatePersistence.

I have successfully done this in JOnAS 5.1 and now am trying to do it in Glassfish 3.

I've tried including Hibernate in my persistence bundle, which did get further, but javassist was unable to see the hibernate classes in the same bundle. I suppose I could inline all of the classes in the bundle, that may solve the problem.
[Message sent by forum member 'bhar99328']

http://forums.java.net/jive/thread.jspa?messageID=396543