Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » loading JPA embeddable classes stored in other bundles(BundleProxyClassLoader cannot load classes outside punit bundle when inside eclipse)
loading JPA embeddable classes stored in other bundles [message #653317] Wed, 09 February 2011 10:49 Go to next message
Jan Bols is currently offline Jan BolsFriend
Messages: 3
Registered: February 2011
Junior Member
I'm running an integration test inside eclipse using gemini JPA (build from trunk using EclipseLink RC4).

I have 1 bundle (A) containing the persistence.xml and my entities and another bundle (B) containing some @Embeddable ExtensionId class that is used from bundle A. Bundle A contains the correct imports in its Manifest.MF.

At startup I find the following exception:
javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [artifact] failed.
Internal Exception: Exception [EclipseLink-7215] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Could not load the field named [id] on the class [class com.mycomp.model.core.id.ExtensionId]. Ensure there is a corresponding field with that name defined on the class.


I found that the problem lies in the org.eclipse.gemini.jpa.classloader.CompositeClassLoader being used. It contains a BundleProxyClassLoader of bundle A (the one containing the persistence unit).

However this BundleProxyClassLoader cannot load classes outside its own bundle.

This is due to the following method:
    protected URL getEntry(String name) {
        URL entry = bundle.getEntry(name);
        if (entry == null) {
            entry = getEclipseProjectEntry(name, entry);
        }
        return entry;
    }

When running inside eclipse, bundle.getEntry(name) will return null and getEclipseProjectEntry also as the @Embeddable class is not in bundle A but bunlde B.

Am I doing something wrong?

Best regards
Jan
Re: loading JPA embeddable classes stored in other bundles [message #653391 is a reply to message #653317] Wed, 09 February 2011 15:59 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Jan,

You are not doing anything wrong. It's just that the OSGi JPA specification doesn't support persistence units distributed across multiple bundles, so what you are attempting is not allowed. For now you will have to package your persistence unit within a single bundle.

-Mike
Re: loading JPA embeddable classes stored in other bundles [message #653807 is a reply to message #653391] Fri, 11 February 2011 10:35 Go to previous messageGo to next message
Jan Bols is currently offline Jan BolsFriend
Messages: 3
Registered: February 2011
Junior Member
Hi Mike, thanks for the reply.

Mike Keith wrote on Wed, 09 February 2011 10:59
It's just that the OSGi JPA specification doesn't support persistence units distributed across multiple bundles


That's awful news. IMHO it's not realistic to expect all classes used in persistence, to be defined in the same bundle.

F.i. I have some Money class used as a value type. It's stored in a separate "model.core" bundle because it's used in several persistence bundles (like "model.accounting" and "model.reporting") that import the Money class.

In the current OSGi JPA spec this would not be allowed because the Money class is not defined in the persistence bundle itself. So I would need a separate Money class for each persistence bundle. (Money1.class in the persistence bundle "model.accounting" and Money2.class in the persistence bundle "model.reporting).

Isn't this rather silly? Are there other options?

Best regards
Jan
Re: loading JPA embeddable classes stored in other bundles [message #653859 is a reply to message #653807] Fri, 11 February 2011 15:30 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Jan,

Quote:
F.i. I have some Money class used as a value type. It's stored in a separate "model.core" bundle because it's used in several persistence bundles (like "model.accounting" and "model.reporting") that import the Money class.

In the current OSGi JPA spec this would not be allowed because the Money class is not defined in the persistence bundle itself. So I would need a separate Money class for each persistence bundle. (Money1.class in the persistence bundle "model.accounting" and Money2.class in the persistence bundle "model.reporting).

Isn't this rather silly? Are there other options?


Yup, it is a little silly. Unfortunately it is what ended up in the spec (due to time constraints and the difficulty of the problem if I recall correctly). We can still attempt to offer support for it in Gemini JPA (although it really adds a lot of complexity). Can you please enter a bug asking for this enhancement (please include your use case). then we can discuss it there and come to a clearer understanding of exactly what you might be expecting. Thanks!

Gemini JPA does support embedded persistence unit jars, so one option is to put all of the persistence units into the same bundle and then you could share the Money class within the same bundle. Not sure if this would be suitable for you.

-Mike
Re: loading JPA embeddable classes stored in other bundles [message #654851 is a reply to message #653859] Thu, 17 February 2011 12:44 Go to previous message
Jan Bols is currently offline Jan BolsFriend
Messages: 3
Registered: February 2011
Junior Member
OK, thanks Mike,

it's in https://bugs.eclipse.org/bugs/show_bug.cgi?id=337425

Regards
Jan
Previous Topic:Gemini JPA 1.0 Milestone 4
Next Topic:Gemini Blueprint 1.0.0.M1 Managed service factory
Goto Forum:
  


Current Time: Tue Mar 19 10:16:59 GMT 2024

Powered by FUDForum. Page generated in 0.03082 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top