javaosgikura

Is it required to import transitive dependencies as bundles to KURA


I am very new to OSGI and KURA. I am tackling with a problem since yesterday and I did not understand its reason.

Please, tell me if my way is wrong.

I am using dropbox-core-sdk (version 3.0.0) in my project. I have downloaded its jar and also, I have researched that it has a dependency on jackson-core (version 2.7.4). I have also downloaded its jar and I have created a bundle with dropbox-core-sdk.jar and jackson-core.jar.

Firstly, I have imported the dependencies (bundle with dropbox and jackson) and then imported my own project.

When I start my project, it throws the following exception;

java.lang.NoClassDefFoundError: javax/net/ssl/HttpsURLConnection
    at com.dropbox.core.http.StandardHttpRequestor.prepRequest(StandardHttpRequestor.java:196)
    at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:70)
    at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:28)
    at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:232)
    at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:100)
    at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:256)
    at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:97)
    at com.dropbox.core.v2.users.DbxUserUsersRequests.getCurrentAccount(DbxUserUsersRequests.java:120)
    at org.eclipse.kura.example.hello_osgi.DropBoxTransfer.<init>(DropBoxTransfer.java:37)
    at org.eclipse.kura.example.hello_osgi.DropBoxUpdateJob.execute(DropBoxUpdateJob.java:20)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

I have two related questions;

  1. When we create a bundle from a public api, should this bundle contain the transitive dependencies of the public api?

  2. Even if I supplied the Dropbox api with its transitive dependencies, why threw the program such an exception?


Solution

  • Typically NoClassDefFoundError happens when a bundle loads a class that is not present in the bundle and there is not Import-Package statement for the package of the class.

    When creating bundles make sure you use a bnd to auto create the Manifest with suitable Import-Package and Export-Package instructions.

    I would always use the build to create a bundle from a jar. As I use maven I would use a maven plugin. See this question for some possible ways to create bundles.