2
votes

I'm going through this OSGi tutorial (with Eclipse, with the PDE addon installed):

http://www.vogella.com/tutorials/OSGi/article.html

Until task 10 everything worked fine. But now I have a problem:

The "Import-Package: org.osgi.framework;version="1.3.0" (which was auto-generated, probably because of the generated Activator class) shows the following error: "No available bundle exports package 'org.osgi.framework'"

In the Activator class I also get resolve error for classes like BundleActivator and BundleContext. I fixed this problem by using an external jar (org.eclipse.osgi), but I'm pretty sure this isn't the right way to do it, since you're supposed to declare any dependencies in the MANIFEST file.

But how do I add the org.eclipse.osgi jar so the import package line in the manifest is enough?

My entire manifest file:

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Internal Bundle-SymbolicName: com.osgi.beispiel.one.bundle.internal Bundle-Version: 1.0.0.qualifier Bundle-Activator: com.osgi.beispiel.one.bundle.Activator Bundle-Vendor: OSGI Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.osgi.framework;version="1.3.0" Bundle-ActivationPolicy: lazy

3

3 Answers

1
votes

The reason for "No available bundle exports package 'org.osgi.framework'" in my workspace was an invalid ${eclipse_home}. The checkbox at "Window - Preferences - Target Platform - Running Platform" was marked with a red icon. I followed "Edit...", select "${eclipse_home}", "Edit...", and checked "This install uses the default configuration area". After leaving the dialogs with "Finish" resp. "OK", the problem was solved.

1
votes

This is an Eclipse configuration issue; by default, Eclipse has a path defined which is used to locate the bundles - this path may not contain the bundles required by your project, so make sure you add the path where the relevant bundles can be found:

enter image description here

0
votes

Add org.eclipse.osgi to the 'Required Plugins' section of the Dependencies tab in the MANIFEST.MF editor (which will add a 'Require-Bundle' line to the MANIFEST.MF).