Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Re: rcp, osgi, and dynamic weaving

Hi Tom

I am in the same boat, also struggling to get dynamic weaving work. Following your instructions and doing some investigation of the code myself, I made quite some progress, but now I've got a problem I can not figure out how to solve it.

Before, describing my problem, I quickly describe what I've done so far:

I checked out the following two projects from svn:

org.eclipse.persistence.jpa.equinox
org.eclipse.persistence.jpa.equinox.weaving

In order to get the hook activated, I exported the weaving bundle (=created a jar), and put this jar into the same directory where the org.eclipse.osgi_XX.jar bundle resides. Further I had to provide the following VM argument, as  suggested:

-Dosgi.framework.extensions=org.eclipse.persistence.jpa.equinox.weaving

So far so good. By checking the console output I could verify that the hook is loaded. And by debuging, I could even verify that the processClass method of the WeaverRegistry class is called. Weaving, however, does not take place, because the list of weaverServices is empty. Investigating the code of the other bundle I noticed, that the EquinoxInitializer is in charge of registering the service the WeaverRegistry requires. But to my astonishment the EquinoxInitializer class has not been "touched" at all, when I started up my application. Further investigations revealed that this class is only used, when the fully qualified name of the class is passed as a constructor argument when instantiating the org.eclipse.persistence.jpa.osgi.PersistenceProvider class.

Having changed my code accordingly, the EquinoxInitializer class is now also involved when it comes to create an entity manager factory. The service mentioned above, however, is still not registered due to an exception that occurs before the respective operation takes place. The exception that occurs is that the nested TempEquinoxEntityLoader classloader is not able to find the entities that are defined in the persistence.xml file. I reckon the problem lies in my bundle-structure, having the domain-models (=my entities) in a different bundle than the class that creates and uses the PersistenceProvider. And this  where I am stuck now. How can I solve this problem?

Note that the bundle where the PersistenceProvider is created has a dependency set to the bundle that contains the domain models, hence the entities should be accessible from this bundle. I  even added this dependency (in desperation) to the org.eclipse.persistence.jpa.equinox bundle, but without success.

This is, how I create the PersistenceProvider to acquire an entity manager:
PersistenceProvider provider = new PersistenceProvider(OSGiPersistenceInitializationHelper.EQUINOX_INITIALIZER_NAME);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("eclipselink.classloader", this.getClass().getClassLoader());
provider.createEntityManagerFactory(emName, properties);


Any advice is highly appreciated!  Thanks in advance!

-Sandro


Back to the top