I have the following situation. I rely on a 3rd party jar called foo.jar. That jar has many non-osgi dependencies. I created a new project "Plug-in from existing JAR archives", selected all of foo.jars non-osgi dependencies and exported it as a "deployable plugin and fragment" called foo.libs.jar.
My RCP4 project is a a feature-based product. In my main RCP project I go to the target file, navigate to the Content tab and checkmark foo.jar and foo.libs.jar. I then go to my project file and select "validate" and receive the message "No problems were detected".
Any clue what I'm doing wrong or need to be doing to get this to work? Do I have to explicitly set foo.libs.jar as a dependency of foo.jar? I've tried to do that in my main projects manifest->dependency tab and the runConfigurations->Plug-ins, and added foo.libs.jar to the feature.xmls->Included plug-ins tab but it didn't seem to work.
Thanks!
===UPDATE===
I think my issue may fall into the case of bundle fragments and embedded dependencies. As an example:
- I create foo.libs.jar. One of the jars inside it is activemq.jar
I need access to javax.jms.ExceptionListener
- The manifest for foo.libs.jar contains activemq.jar in the
Bundle-ClassPath, and javax.jms in the Export-Package sections
- foo.jar contains foo.libs.jar in its Class-Path. It contains
javax.jms in its Import-Package and Export-Package sections
- I created a "Plug-in from existing JAR archives" project which has
foo.jar and foo.libs.jar in it.
- The manifest for the project has foo.jar and foo.libs.jar in the
Bundle-Classpath section. The Import-Package section contains
javax.jms
- If I export this bundle to my project, and run validate I get
errors saying javax.jms cannot be found.
- If I omit the javax.jms from the bundles Import-Package there
are no validation errors but I will get a ClassNotFoundException
I kinda feel like this may be an issue with embedded jars and Bundle-ClassPaths...
My bundle has
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: my.name
Bundle-SymbolicName: my.name
Bundle-Version: 1.0.0
Bundle-ClassPath: foo.jar
Export-Package: list_of_my_packages
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
And foo.jar has
Manifest-Version: 1.0
Bnd-LastModified: 1489769501680
Bundle-ManifestVersion: 2
Bundle-Name: foo
Bundle-SymbolicName: foo
Bundle-Version: 1.0.0
Class-Path: foo.libs.jar
Created-By: 1.8.0_71 (Oracle Corporation)
Export-Package: javax.jms (and other stuff, omitted)
Import-Package: javax.jms;resolution:=optional (and other stuff, omitted)
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-2.4.0.201411031536
And foo.libs.jar has
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Foo libs
Bundle-SymbolicName: foo.libs
Bundle-Version: 1.1.0
Bundle-ClassPath: activemq-all.jar, (and others which I ommitted)
Export-Package: javax.jms, (and others which I ommitted)
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
The question lacks details, but the issue with "no class found" is quite typical for OSGI.
Check the MANIFEST.MF of both of your bundles. foo.libs.jar must have a declaration of a package for your "missing" class in 'Export-Package' directive, while foo.jar must have same package in 'Import-Package'. Since you managed to reach to the point when you get an exception, it seems like you missing package declaration for some.class.in.a.jar.in.foo.libs.jar in 'Import-Package' of foo.jar.
Main rule is following: a bundle may access only the classes within itself + the ones, imported via manifest. There are exceptions like bundle fragments and embedded dependencies, but I believe we can omit them for this case.
Generally, problem is solved when you properly set both 'Import-' and 'Export-Package' directives in manifests of your bundles. If you need more detailed help, please provide more details about how you make foo.jar and foo.lib.jar (by hands, by maven plugin, by gradle, which settings you use etc.)