Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Can't get Gemini JPA working under Felix
Can't get Gemini JPA working under Felix [message #643005] Fri, 03 December 2010 16:02 Go to next message
Nick Wilson is currently offline Nick WilsonFriend
Messages: 6
Registered: July 2009
Junior Member
Hi,

I'm starting a felix 3.0.6 container with the following bundles:


    osgi.enterprise.jar
    org.apache.felix.http.bundle-2.0.4.jar
    org.apache.felix.webconsole-3.1.6.jar
    javax.persistence_2.0.3.v201010191057.jar
    org.eclipse.persistence.antlr_2.2.0.v20101117-r8503.jar
    org.eclipse.persistence.asm_2.2.0.v20101117-r8503.jar
    org.eclipse.persistence.core_2.2.0.v20101117-r8503.jar
    org.eclipse.persistence.jpa_2.2.0.v20101117-r8503.jar
    org.eclipse.gemini.jpa_1.0.0.M3-incubation.jar
    org.eclipse.gemini.jpa.weaving_1.0.0.M3-incubation.jar
    org.eclipse.gemini.jpa.samples_1.0.0.M3-incubation.jar


All bundles start ok, no errors, and I see the "Gemini JPA Sample started" message.
When I look in the Felix web console I was expecting to see a "javax.persistence.EntityManagerFactory" or a "org.osgi.service.jpa.EntityManagerFactoryBuilder" service registered, but it's not there. Aside from the Felix services the only one I see is:


    javax.persistence.spi.PersistenceProvider


I get the same problem when creating my own persistence unit. I include the "Meta-Persistence" manifest entry to point to the persistence.xml, but no EntityManagerFactoryBuilder service and no log entries.

Am I missing something?
Regards,

Nick
Re: Can't get Gemini JPA working under Felix [message #643028 is a reply to message #643005] Fri, 03 December 2010 17:15 Go to previous messageGo to next message
Nick Wilson is currently offline Nick WilsonFriend
Messages: 6
Registered: July 2009
Junior Member
I think this is a bug in the PersistenceBundleExtender class:

// We found a persistence unit bundle that has already been installed.
// Refresh it so it will go through the resolving state again and client
// bundles that are waiting for the EMF service will not be hosed
if (b.getState() != Bundle.INSTALLED) {
addToRefreshingBundles(b);
PackageAdmin admin = getPackageAdmin(osgiJpaProvider.getBundleContext());
debug("GeminiExtender refreshing packages of bundle ", b);
admin.refreshPackages(new Bundle[] { b });
}

In my test the gemini JPA samples bundle is in the INSTALLED state when it gets to this code, so isn't refreshed.

public void bundleChanged(BundleEvent event) {
...
if (eventType == BundleEvent.INSTALLED) {
tryAssigningPersistenceUnitsInBundle(b);

}

As the sample is in the INSTALLED state already, tryAssigningPersistenceUnitsInBundle never gets called...

else if (eventType == BundleEvent.STARTING) {
if (isAssigned(b)) {
if (!isLazy(b)) {
registerPersistenceUnitsInBundle(b);
}
}
}

... so when it starts, "isAssigned" returns false, so the persistence unit doesn't get registered.


I also think the first piece of code that restarts bundles seems quite unfriendly. It shouldn't need to restart them to register the persistence units.

Regards,

Nick
Re: Can't get Gemini JPA working under Felix [message #643382 is a reply to message #643028] Mon, 06 December 2010 17:11 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Nick,

The problem you are seeing is unfortunately due to a bug in Felix. See https://issues.apache.org/jira/browse/FELIX-2456 for more details. I have talked to the Felix guys and they are aware of it, but I am going to be putting out another Gemini JPA milestone soon that includes a workaround since you are obviously not the only person that is hitting this.

An immediate workaround is that you can ensure that Gemini JPA is started before the persistence unit bundles, which will prevent a refresh from being necessary. (Note that a refresh is necessary when the bundle is already resolved because the class may need to be weaved, something that cannot be done once the class is already loaded). I recognize that is a bit of a pain, though.

-Mike

[Updated on: Mon, 06 December 2010 17:11]

Report message to a moderator

Re: Can't get Gemini JPA working under Felix [message #643404 is a reply to message #643382] Mon, 06 December 2010 18:36 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
I looked into putting a workaround for this in Gemini, but there does not seem to be a straightforward way to do it and still support weaving.

The Felix folks are going to try to put a patch in for the snapshot build tomorrow, and they are also going to put out a release next week, which should fix this. Does that work for you?

Thanks,
-Mike
Re: Can't get Gemini JPA working under Felix [message #644101 is a reply to message #643404] Thu, 09 December 2010 13:59 Go to previous message
Nick Wilson is currently offline Nick WilsonFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks Mike, that's great. I can work around it for now.
Regards,

Nick
Previous Topic:Making Blueprint working with Gemini JPA and Gemini Naming
Next Topic:Spring configuration files and Gemini blueprint
Goto Forum:
  


Current Time: Tue Mar 19 06:58:14 GMT 2024

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

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

Back to the top