1
votes

I'm learning dealing with osgi bundles using apache felix. I'm using maven-bundle-plugin to generate the manifest file.

I created a first bundle that contains only an interface and I export it to be used by others. The second bundle contain a class that implements the interface created in the first bundle. I configured the second bundle to import the package exported by the first one.

When I compile the second bundle, I get an error telling me that he can not resolve the interface.

I'm not sure that I understood how bundles works ...

Thank you very much ...

[Edit] More information : I got the error when I compile using maven :

[INFO] Compilation failure
....../ServeurImpl.java:[17,36] error: cannot find symbol

ServeurImpl.java (line 17) :

public class ServeurImpl implements Serveur {

Serveur is an interface created in the first bundle.

1
Please post more details on the error. Is it a maven error? eclipse error? What you are doing is correct conceptually, your error must be somewhere else. Your impl pom (not only it's manifest) should have a maven depedency to the API pom - Hilikus
Thanks for your response. I added some information. - javacurve
Are you sure you have a dependency in your ServeurImpl pom to the Serveur artifact? - Hilikus
It's important to note that at this stage, the error has NOTHING to do with OSGi, which is a runtime technology. What you have is a build error due to a missing dependency in your build configuration. Until you've actually built something, don't worry too much about OSGi. - Neil Bartlett

1 Answers

1
votes

Since your deploying the API in a separate bundle you would need something in the pom.xml file of the bundle implementing the API to say its available.

In your pom.xml put something like this:

    <dependency>
        <groupId>the.group</groupId>
        <artifactId>Serveur</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>bundle</type>
        <scope>provided</scope>
    </dependency>

'Provided' means the container would provide it... you said Felix.

Hope that helps.