cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with external libraries when developing IoT Gateway Interceptor?

Former Member
0 Kudos

I am currently developing an IoT Gateway Interceptor using some external libraries such as libraries related to org.apache.http.client.*. When testing the interceptor on my local machine in eclipse without the gateway, everything works as planned, but when executed as an OSGi bundle within the Gateway, only the InterceptorActivator starts up but no message of the actual interceptor is found in the log. There are just dozens of error messages in the error log in folder "configuration" of the type "java.lang.NoClassDefFoundError: org/apache/http/client/ [...]".

I figure that somehow the included libraries went missing when building the OSGi bundle / when clicking "Build Iot Interceptor in Eclipse.

Thanks in advance for your help!

Accepted Solutions (0)

Answers (1)

Answers (1)

andrea_bisogno
Discoverer
0 Kudos

Hi Fabian,

we'll look into the behavior you obtain exporting the bundle through the "Build Iot Interceptor in Eclipse" button. In the meantime could you follow this alternative way to configure and export your bundle?

Project setup

  • 1.Add the library to the build path: right-click on project -> build path -> configure build path -> add external jar. For convenience, place the jar within a “lib” folder under the project main folder
  • 2.Add the Bundle-classpath directive to the Manifest file, including the library placed under the “lib” folder (e.g. Bundle-ClassPath: .,lib/org.eclipse.paho.client.mqttv3-1.2.0.jar)
  • 3.Modify the build.properties adding the “lib” folder: this allows to include the third-party jar when building the interceptor project. A resulting build.properties file would look as follows

source.. = src/

bin.includes = META-INF/,\

.,\

OSGI-INF/,\

lib/

Building the project

Right-click on the project -> export -> deployable plug-in and fragments -> next. Select the interceptor project, then click on “finish”.