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

Bug 343843

Summary: Invalid usage of "Require-Bundle"-attribute prevents bundle from starting
Product: [Eclipse Project] Equinox Reporter: Markus Tiede <markus.tiede>
Component: FrameworkAssignee: equinox.framework-inbox <equinox.framework-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: pwebster, tjwatson
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Markus Tiede CLA 2011-04-26 09:40:20 EDT
After switching to the Eclipse Indigo M7 "Version: 3.7.0 Build id: I20110310-1119", an invalid usage of a "Require-Bundle"-attribute prevented one of our bundles from starting: Missing required bundle javax.persistence_[2.0.3,3.0.0).

After migrating from Eclipse 3.6 SR 2 to Eclipse Indigo M7 one of our main bundles "org.eclipse.jubula.client.core" failed during start:

osgi> bundle org.eclipse.jubula.client.core
org.eclipse.jubula.client.core_0.9.0.201104260531 [154]
  Id=154, Status=INSTALLED
  No registered services.
  No services in use.
  No exported packages
  No imported packages
  No fragment bundles
  No named class spaces
  No required bundles

osgi> diag org.eclipse.jubula.client.core
reference:file:plugins/org.eclipse.jubula.client.core_0.9.0.201104260531.jar [154]
  Direct constraints which are unresolved:
    Missing required bundle javax.persistence_[2.0.3,3.0.0).

Although the "javax.persistence"-bundle was available and "ACTIVE":

osgi> bundle javax.persistence
javax.persistence_2.0.3.v201010191057 [11]
  Id=11, Status=ACTIVE
  No registered services.
  No services in use.
  Exported packages
    javax.persistence.spi; version="2.0.3"[exported]
    javax.persistence; version="2.0.3"[exported]
    javax.persistence.criteria; version="2.0.3"[exported]
    javax.persistence.metamodel; version="2.0.3"[exported]
    org.osgi.service.jpa; version="1.0.0"[exported]
  Imported packages
    org.osgi.framework; version="1.6.0"<org.eclipse.osgi_3.7.0.v20110304 [0]>
    javax.sql; version="0.0.0"<org.eclipse.osgi_3.7.0.v20110304 [0]>
  No fragment bundles
  Named class space
    javax.persistence; bundle-version="2.0.3.v201010191057"[provided]
  No required bundles

The same version of our bundle starts in the previous service release (3.6.2) of Eclipse without any problems.

We discovered that we were using an import package attribute jpa="2.0" for the "javax.persistence" bundle dependency which may never have actually had an effect. The line from the "Require-Bundle:" section was as follows:
javax.persistence;bundle-version="[2.0.3,3.0.0)";jpa="2.0";visibility:=reexport

This was changed to:
javax.persistence;bundle-version="[2.0.3,3.0.0)";visibility:=reexport

Removing this attribute resolved the problem for Eclipse Indigo M7. 

The question is now - why did this not lead to an error when working with Eclipse 3.6.2 and why does this problem first occur when trying to start the bundle (instead of e.g. during installation of the feature it belongs to)?
Comment 1 Thomas Watson CLA 2011-04-26 09:50:57 EDT
In OSGi R4.3 arbitrary matching attributes were added to Require-Bundle and Fragment-Host (bug 328508).  Equinox 3.7 implements R4.3 Core Framework specification, this is why you are seeing this issue in 3.7 only.

*** This bug has been marked as a duplicate of bug 329375 ***
Comment 2 Thomas Watson CLA 2011-04-26 09:52:50 EDT
(In reply to comment #0)
> The question is now - why did this not lead to an error when working with
> Eclipse 3.6.2 and why does this problem first occur when trying to start the
> bundle (instead of e.g. during installation of the feature it belongs to)?

This is a question for p2.  You should open a bug against p2.  p2 currently does not pay attention to the arbitrary matching attributes on the Require-Bundle constraints.