0

I am writing from scratch an OSGi bundle for Eclipse smarthome and need to export a certain package. This is needed because at the moment the karaf console is showing me this error:

Unresolved requirement: Import-Package: com.pubnub.api

In the manifest file i can see i import that same package, among others. I used maven to import it, following the official documentation here.

OSGi dev support is telling me I have to "export com.pubnub. API package in order for my bundle to import it", but I do not know how to do this. It seems I should "find or make a bundle which exports the PubNub API" but this answer is confusing me.

I suppose I would need to add a line in the manifest like "export-package etc" somewhere, but I don't know in which manifest, or if this is the right way at all. I'm a beginner in the OSGi framework.

I tried searching in similar threads (like this and this) but I don't think they're helping in my case.


This is my manifest file, for clarity:

Import-Package: org.eclipse.smarthome.core.library.types, org.eclipse.smarthome.core.thing, org.eclipse.smarthome.core.thing.binding, org.eclipse.smarthome.core.types, com.google.gson;version="[2.8,3)", com.pubnub.api, com.pubnub.api.builder, com.pubnub.api.callbacks, com.pubnub.api.endpoints.pubsub, com.pubnub.api.models.consumer, com.pubnub.api.models.consumer.pubsub, com.pubnub.api.models.consumer.pubsub.message_actions, com.pubnub.api.models.consumer.pubsub.objects, org.slf4j;version="[1.7,2)"

This is my pom:

<parent>
   <groupId>org.openhab.addons.bundles</groupId>
   <artifactId>org.openhab.addons.reactor.bundles</artifactId>
   <version>2.5.3-SNAPSHOT</version>
 </parent>

 <artifactId>org.openhab.binding.safehome_se</artifactId>

 <name>openHAB Add-ons :: Bundles :: SafeHome_SE Binding</name>

 <dependencies>

   <dependency>
     <groupId>com.pubnub</groupId>
     <artifactId>pubnub-gson</artifactId>
     <version>4.31.0</version>
     <scope>provided</scope>
   </dependency>
 </dependencies>
  • You will have to provide some info about what maven plugins you use ... – Peter Kriens Apr 03 '20 at 12:43
  • I thought i wasn't using any, because my pom didn't have any plugins tag. However, enabling "Show effective pom" it shows - among what i suppose to be maven default plugins' - it shows bnd, karaf and openhab sat (org.openhab.tools.sat) – Alessandro Apr 03 '20 at 17:00
  • There are different bnd plugins. However, in general they have either a manifest section in the pom or the have a bnd file. Normally you don't specify an Import-Package, this is calculated by bnd ... Can you share your workspace because you seem rather lost? – Peter Kriens Apr 04 '20 at 15:26

1 Answers1

0

You have to install a bundle that exports the package. You can install it from karaf command line console using the command

bundle:install mvn:<groupId>/<artifactId>/<version>