0
votes

I have an RCP project in which I ran into problems. I have an OSGI jar lets say jar-A which imports some packages from another osgi jar lets say jar-B. Now I have one more osgi jar-C that has the same package structure as jar-A but different classes in it.

I have a plugin say "plugin-A" that has both jar-A and jar-B in its build path and as a runtime dependency. Now plugin-A exports the jar-A and jar-B's packages.

I have one more "plugin-B" that has "jar-C" in its build path and as a runtime dependency. Now plugin-B has plugin-A as a required bundle. So technically it should be able to access "jar-A" and "jar-B's packages right?

Now plugin-B has a class that imports packages from jar-A and jar-C's classes. It is recognizing jar-C's classes fine since it is in the build path, but it is not recognizing jar-A's classes. It says "The type of class some X cannot be resolved. It is indirectly referenced from required .class files", where the some X class is in jar-A. Shouldn't this X class be recognized from the required bundle plugin-A which exports this class? When I put this jar-A in plugin-B's bundle path I am not getting this issue anymore.

1
This is a build-time error, not an OSGi problem. Could you explain exactly what you mean when you say "'plugin-B' that has 'jar-C' in its build path and as a runtime dependency"? This is a little vague and doesn't help in understanding the problem. - Neil Bartlett
I added jar-C in plugin-B's .classpath file as well as under MANIFEST.MF file's Class-Path: header. - user1623627

1 Answers

0
votes

I'm not sure I follow all that, but only packages that are listed in the Export-Package entry in the plugin's MANIFEST.MF file are available to other plugins.

In the MANIFEST.MF editor specify these on the 'Runtime' tab in the 'Exported Packages' section.

An example Export-Package section from one of my plugins:

Export-Package: greg.music.core.common,
 greg.music.core.databinding,
 greg.music.core.e4util,
 greg.music.core.editor,
 greg.music.core.preferences,
 greg.music.core.progress,
 greg.music.core.services,
 greg.music.core.showin,
 greg.music.core.util,
 greg.music.core.views,
 greg.music.core.xml