Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338700

Summary: Blueprint can't co-exist with osgi.enterprise bundle
Product: [RT] Gemini.Blueprint Reporter: Shaun Smith <shaun.smith>
Component: CoreAssignee: Glyn Normington <glyn.normington>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: glyn.normington, m, michael.keith, shaun.smith, tom.ware
Version: 1.0.0.RELEASE   
Target Milestone: 1.0.1.RELEASE   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
remove org.osgi classes from core none

Description Shaun Smith CLA 2011-03-02 11:30:46 EST
Blueprint core contains org.osgi.framework.blueprint.* classes which are not exported.  Blueprint extender bundle optionally imports org.osgi.framework.blueprint.* packages.  Deploying the osgi.enterprise bundle with blueprint can lead to class consistency issues (see stack below) as discovered when deploying Blueprint with DB Access and the osgi.enterprise bundle.

Blueprint core should import and export the org.osgi.framework.blueprint.* packages it contains so that, if present, the osgi.enterprise bundle will be used as the source of the org.osgi.framework.blueprint.* packages.  


Exception in thread "SpringOsgiExtenderThread-1" java.lang.NoClassDefFoundError: org/eclipse/gemini/blueprint/blueprint/container/SpringBlueprintContainer
	at org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintContainerProcessor.createBlueprintContainer(BlueprintContainerProcessor.java:243)
	at org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintContainerProcessor.preProcessRefresh(BlueprintContainerProcessor.java:162)
	at org.eclipse.gemini.blueprint.extender.internal.activator.LifecycleManager$1.run(LifecycleManager.java:220)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.eclipse.gemini.blueprint.blueprint.container.SpringBlueprintContainer
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	... 4 more
Comment 1 Shaun Smith CLA 2011-03-02 11:32:25 EST
In some cases an exception isn't thrown but instead you get a message like:

INFO: Bundle Example is not type compatible with extender gemini-blueprint-extender (Incubation); ignoring bundle...
Comment 2 Shaun Smith CLA 2011-03-03 08:16:26 EST
Correction, the Blueprint core bundle does in fact export org.osgi.service.blueprint.* packages.  The lack of import is the issue.

Also note that the packages in question are under org.osgi.service.blueprint, not org.osgi.framework.blueprint as I wrote in the initial bug description.
Comment 3 Magnus Jungsbluth CLA 2011-11-13 18:16:52 EST
Created attachment 206907 [details]
remove org.osgi classes from core

The attached patch should fix this issue:
- Adds a dependency on org.osgi.enterprise 4.2.0 (maven central)
- removed org.osg.* packages from blueprint-core
- changed template.mf, s.t. the import-package statements are correct
- changed one test at 3 places where obviously some blueprint.reflect interface changed (Please verify that the solution is still correct)

I actually commented out the jarjar plugin from the root manifest to be able to build. What exactly is its purpose and where can it be obtained from?
Comment 4 Glyn Normington CLA 2012-11-20 08:38:18 EST
(In reply to comment #3)
> Created attachment 206907 [details]
> remove org.osgi classes from core
> 
> The attached patch should fix this issue:
> - Adds a dependency on org.osgi.enterprise 4.2.0 (maven central)
> - removed org.osg.* packages from blueprint-core
> - changed template.mf, s.t. the import-package statements are correct
> - changed one test at 3 places where obviously some blueprint.reflect
> interface changed (Please verify that the solution is still correct)
> 
> I actually commented out the jarjar plugin from the root manifest to be able
> to build. What exactly is its purpose and where can it be obtained from?

Thanks for the patch Magnus, but it's larger than is strictly necessary to fix the bug.
Comment 5 Glyn Normington CLA 2012-11-20 08:51:45 EST
Careful analysis of the org.osgi.* package exports is necessary. I'll add a separate comment for each bundle.

The core bundle exports:

org.osgi.service.blueprint.container;version="1.0.0";uses:="org.osgi.framework,org.osgi.service.blueprint.reflect",
org.osgi.service.blueprint.reflect;version="1.0.0"

and imports these with suitable version ranges:

org.osgi.service.blueprint.container;version="[1.0.0,1.1)",
org.osgi.service.blueprint.reflect;version="[1.0.0,1.1)"

NB. the exclusive upper bound of 1.1 is necessary as Gemini Blueprint implements these interfaces. See "Importer Policy" in the semantic versioning white paper for the rationale: http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf.
Comment 6 Glyn Normington CLA 2012-11-20 08:53:25 EST
The extender bundle exports (since bug 351755 was fixed - a few minutes ago):

org.osgi.service.blueprint;version="1"

Now the OSGi enterprise 5.0 companion JAR (apparently intended for compilation only rather than runtime, but let's overlook that for our current purposes) exports the following:

org.osgi.service.blueprint.reflect;version="1.0.1",
org.osgi.service.blueprint.container;uses:="org.osgi.service.blueprint.reflect,org.osgi.framework";version="1.0.2"

It makes no mention of the package org.osgi.service.blueprint and so there is no need for the extender to import that package in order to co-exist with the OSGi enterprise JAR. Also, it is not clear that a substitutable export would be appropriate for this particular package as it is special purpose and contains no classes. See bug 351755 for details plus a reference to the OSGi spec.
Comment 7 Glyn Normington CLA 2012-11-20 08:57:46 EST
For the record, note that the OSGi enterprise 4.2 companion JAR exports the following:

org.osgi.service.blueprint.reflect;version="1.0.1",
org.osgi.service.blueprint.container;uses:="org.osgi.service.blueprint.reflect,org.osgi.framework";version="1.0.1"

and imports the following:

org.osgi.service.blueprint.container;resolution:=optional;version="[1.0,2)",
org.osgi.service.blueprint.reflect;resolution:=optional;version="[1.0,2)"

so neither does this mention the package org.osgi.service.blueprint, further justifying the decision not to import that package in the extender bundle.
Comment 8 Glyn Normington CLA 2012-11-20 08:59:20 EST
The io bundle neither exports nor imports any org.osgi.* packages and therefore does not need changing.
Comment 9 Glyn Normington CLA 2012-11-20 09:10:01 EST
Since the problem is not present at master (destined for the 2.0 release), I checked back levels to see where the bug exists.

The bug is present in Gemini Blueprint 1.0.0.RELEASE, but is fixed in 1.0.1.RELEASE (and 1.0.2.RELEASE).
Comment 10 Glyn Normington CLA 2012-11-20 09:10:11 EST

*** This bug has been marked as a duplicate of bug 385307 ***