Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini JPA Package Refresh
Gemini JPA Package Refresh [message #759020] Fri, 25 November 2011 15:42 Go to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Hi,

Gemini JPA is performing a package refresh right after my bundle is
started. This is problematic because the bundle is started twice. I
wonder if the behavior is required or can be avoided.

Looking through the code I found an option to turn it off (with the
default being ON). However, the comment says that it may only be turned
ON if waving is not required
(GeminiProperties.refreshPersistenceBundles()).


Here is the issue:

* Launch JUnit plug-in test
* Test runner starts bundle X (static Activator.instance is set)
* Test runner loads test class Y
* Bundle X is stopped (static Activator.instance is clear)
* Bundle X is started again (static Activator.instance is set [1])
* Test class Y method is executed which calls Activator.instance [2]


[1] The issue is that this is actually a new class loaded with a new
class loader (because of the package refresh)

[2] Test fails because Activator.instance is null because of [1].


A possible workaround is to modify the test runner to somehow detect
package refreshes and to re-start the tests. I wonder if that is
possible at all...

Thus, before I go down that path I'm wondering if it's possible to avoid
the package refresh behavior when executing tests.

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Gemini JPA Package Refresh [message #759025 is a reply to message #759020] Fri, 25 November 2011 16:12 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Gunnar,

I'll make a few comments about the refreshing and then you can make your own decision Smile

1) Refreshing a bundle is done because weaving requires that the weaving hook be installed *before* the entity classes in the bundle have been loaded and if a bundle has already been started or even resolved then we have no way of knowing what classes have already been loaded.

2) Refreshing will only happen if the persistence bundle was detected to have been resolved before Gemini JPA got started (due to 1). If the bundle is installed/resolved after Gemini JPA then the refreshing will not happen - thus it only happens when the situation warrants refreshing.

3) You may turn off refreshing and still use weaving and "take your chances" that you will win the race, or you could control the ordering of the bundles at startup to ensure that Gemini JPA is active before the persistence bundles.

4) In our Gemini tests we do have a bundle that stores the test state and that does not have any dependencies on either the test cases or SUTs, thus does not get refreshed, so when tests run they first check the test state to see if they have been run yet. Not the prettiest, but it seems to work okay.

5) In the latest OSGi release, "capabilities" were added and we plan to create one that will ameliorate this situation in the next release. If the persistence bundle includes a required capability then it would not get resolved until Gemini JPA was active.

-Mike
Re: Gemini JPA Package Refresh [message #759061 is a reply to message #759025] Fri, 25 November 2011 21:15 Go to previous messageGo to next message
Krum Tsvetkov is currently offline Krum TsvetkovFriend
Messages: 164
Registered: July 2009
Senior Member
Hi Gunnar,

Just for reference:
- the ticket about refresh and the option to disable it (inside there is also some discussion why the refresh is performed) https://bugs.eclipse.org/bugs/show_bug.cgi?id=337157
- The proposal to use generic capabilities https://bugs.eclipse.org/bugs/show_bug.cgi?id=360246

I've also often experienced the problem with the test. The workaround I've found so far is to influence thestartup order - let gemini.jpa.start earlier, and thepersistence bundles later. Deffinitely not a perfect solution, and I m not sure it always works, but you can give it a try.

Krum
Re: Gemini JPA Package Refresh [message #760789 is a reply to message #759025] Mon, 05 December 2011 09:48 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 25.11.2011 17:12, schrieb Mike Keith:
> 2) Refreshing will only happen if the persistence bundle was detected to have been resolved before Gemini JPA got started (due to 1). If the bundle is installed/resolved after Gemini JPA then the refreshing will not happen - thus it only happens when the situation warrants refreshing.

That's interesting. In my test bundle I have a "Require-Bundle"
dependency on "org.eclipse.gemini.jpa". Thus, when Equinox starts my
bundle it ensures that "org.eclipse.gemini.jpa" is started first. My
test bundle is still refreshed, though. Should I open a bug to
investigate further?

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Gemini JPA Package Refresh [message #760865 is a reply to message #760789] Mon, 05 December 2011 13:29 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 05.12.2011 10:48, schrieb Gunnar Wagenknecht:
> That's interesting. In my test bundle I have a "Require-Bundle"
> dependency on "org.eclipse.gemini.jpa". Thus, when Equinox starts my
> bundle it ensures that "org.eclipse.gemini.jpa" is started first. My
> test bundle is still refreshed, though. Should I open a bug to
> investigate further?

I stand corrected. I think it may be a behavior that was the case in the
old (pre-OSGi) world. I did not find any statement regarding this in the
OSGi spec.

-Gunnar


--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Gemini JPA Package Refresh [message #760929 is a reply to message #760865] Mon, 05 December 2011 16:05 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Yeah, unfortunately something being resolved beforehand does not mean it gets started first. This is where the capabilities *could* solve the problem since one could specify something like effective:=active, but unfortunately there is currently no support for the effective directive being anything other than "resolve".
Previous Topic:Gemini DBAccess - Support for H2/HSQLDB
Next Topic:JPA + EclipseLink in OSGi environment
Goto Forum:
  


Current Time: Tue Mar 19 05:25:45 GMT 2024

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

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

Back to the top