1

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?

Ad Infinitum
  • 3,560
  • 27
  • 33

1 Answers1

1

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.

Community
  • 1
  • 1
Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • When I am creating bundle, I am using eclipse file -> new -> other -> Plug-in From Existing JAR Archieves. Is it not a good way to create bundle? – Ad Infinitum Mar 27 '17 at 13:39
  • and additionally, how would I know that which package should I import from "java.lang.NoClassDefFoundError: javax/net/ssl/HttpsURLConnection" this statement? – Ad Infinitum Mar 27 '17 at 13:40
  • The package you need to import is "javax.net.ssl". The eclipse pde support sucks. I recommend to build the bundle using a maven build. See answer for options to create a bundle. – Christian Schneider Mar 27 '17 at 15:26
  • Thank you very much for the tip. After your tip, I started to use bnd command line. What I still do not understand that Should I include the transitive dependencies when I am converting jars into bundle with bnd? – Ad Infinitum Mar 27 '17 at 16:57
  • It depends on how you want to do your deployment. If your dependencies are bundles then you typically do not want to embed them. Likewise you can create one bundle per dependency or one bundle including all transitive deps... but better do not mix the two approaches too much. – Christian Schneider Mar 28 '17 at 12:13