Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Startorder of bundles
Startorder of bundles [message #908387] Wed, 05 September 2012 09:48 Go to next message
Florian Pirchner is currently offline Florian Pirchner
Messages: 87
Registered: July 2009
Member

Hi together,

yesterday evening i spent a lot of time to run a JUnit Plugin test based on Gemini JPA.

My big problem was, that the persistence bundle (containing jpa entities) and the bundle containing the tests became restarted automatically by gemini. (Sure, since the class files may be changed!)

So i read a lot of blog entries and detected the workaround by start level.

So i ensured, that the start level of gemini.jpa is lower (eg 4) as the start level of my persistence bundle (eg 5).
But it does not work! Everytime the persistence bundle becomes restarted and i am getting class loader problems.

So i checkedout source from git and detected, that there is maybe a bug in gemini. I am not an expert about gemini jpa, but if i am changing the following, then everything seems to be fine and the persistence bundle is not restarted anymore, if the start levels are set properly.


I changed PersistenceBundleExtender#lookForExistingBundles():
// We found a persistence unit bundle.
	if (GeminiProperties.refreshPersistenceBundles()) {
		// If bundle is active then refresh it and push it through
		// the life cycle again
		// so it will go through resolving and we can assign it a
		// provider, etc.
		// if ((b.getState() != Bundle.INSTALLED) && (b.getState()
		// != Bundle.UNINSTALLED)) {
		if (b.getState() == Bundle.ACTIVE) {
			refreshBundle(b);
		} else if (b.getState() == Bundle.RESOLVED) {
			tryAssigningPersistenceUnitsInBundle(b);
		}


I added following code. If the persistence bundle was found, and its state is just resolved, i try to assign it.
} else if (b.getState() == Bundle.RESOLVED) {
	tryAssigningPersistenceUnitsInBundle(b);
}


Since i am not an expert, i thought i will ask here before opening a bug.

What do you think about the change above?

Best,
Florian
Re: Startorder of bundles [message #908482 is a reply to message #908387] Wed, 05 September 2012 13:07 Go to previous messageGo to next message
Michael Keith is currently offline Michael Keith
Messages: 215
Registered: July 2009
Senior Member
Hi Florian,

A couple of comments about this.

Firstly, in order for EclipseLink to be able to weave the entity classes it needs to hook in the classfile weaver before any entity class can possibly have been loaded, and the only safe way to do that is to ensure it occurs *before* the bundle is resolved and has its classloader set up. That means that if Gemini JPA finds a persistence bundle and sees that it has already been resolved then it must push the bundle back into the pre-resolve stage by refreshing it and causing any bundle that may have already been wired to it (and possibly loaded a class from it) to refresh also. That should hopefully explain why the assignment (which installs the weaver) happens when it does, and why the bundle can't be assigned if it has already been resolved.

There are a couple of ways to avoid this:

1) You can turn off weaving. See here for a description of what that implies and how it is done.

2) You can do the EclipseLink weaving statically. See this section for more information about static weaving. This will essentially perform the weaving beforehand, so by the time you install your bundle it will already have been woven and Gemini JPA will never need to refresh it (you can set the Gemini refreshing flag to false).

Hope this helps,

-Mike
Re: Startorder of bundles [message #908508 is a reply to message #908482] Wed, 05 September 2012 13:52 Go to previous messageGo to next message
Florian Pirchner is currently offline Florian Pirchner
Messages: 87
Registered: July 2009
Member

Hi Mike,


thanks. Before "resolved" was the missing link. I thought it is before
"started". Now i understand why the bundle is restarted in resolved state.

Best,
Florian
Re: Startorder of bundles [message #912325 is a reply to message #908508] Thu, 13 September 2012 10:50 Go to previous messageGo to next message
Florian Pirchner is currently offline Florian Pirchner
Messages: 87
Registered: July 2009
Member

Right now i am wondering about the best practice using gemini jpa and
how other projects are using it.

Question to products that already use gemini:
How are you using gemini jpa?
- Did you turn off dynamic weaving?
- Or did you change the startorder of the bundles a way, that gemini jpa
does not have to re-resolve the persistence unit?
- Or are you handling the re-resolving internally?

Would be really interesting for me. Then i get an idea what will be best
practice and how i can use it.

Thanks a lot for any hints and discussion...
Best,
Florian
Re: Startorder of bundles [message #913125 is a reply to message #912325] Fri, 14 September 2012 20:32 Go to previous message
Michael Keith is currently offline Michael Keith
Messages: 215
Registered: July 2009
Senior Member
Hi Florian,

You might want to start another thread with a better subject to increase the visibility of your question.

-Mike
Previous Topic:Deploy Spring-based war into Gemini Web.
Next Topic:Gemini JPA 1.1.0 RC1 now available
Goto Forum:
  


Current Time: Thu Oct 02 10:28:51 GMT 2014

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

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