BndTools, How to add a non-OSGi JAR?

隐身守侯 提交于 2019-12-24 00:59:22

问题


BndTools, How to add a non-OSGi JAR? I wanted to add jcraft Libraries into my osgi project. Using plain JAR breaks the whole project. Missing requirement wiring package

ERROR: Bundle com.herle.iiot.application.installation [6] Error starting file:/D:/HERLE/Data/iot-sdk/FelixLauncher/bundle/com.herle.iiot.application.installation-1.5.0.jar
(org.osgi.framework.BundleException: Unable to resolve com.herle.iiot.application.installation [6](R 6.0): missing requirement [com.herle.iiot.application.installation [6](R 6.0)] osgi.w
iring.package; (osgi.wiring.package=com.jcraft.jzlib) Unresolved requirements: [[com.herle.iiot.application.installation [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.jcraft.jzlib)]
)
org.osgi.framework.BundleException: Unable to resolve com.herle.iiot.application.installation [6](R 6.0): missing requirement [com.herle.iiot.application.installation [6](R 6.0)] osgi.wi
ring.package; (osgi.wiring.package=com.jcraft.jzlib) Unresolved requirements: [[com.herle.iiot.application.installation [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=com.jcraft.jzlib)]
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Unknown Source)
[Device Manager] info: Passive start
Watched path D:\HERLE\Data\iot-sdk\FelixLauncher\fileinstall key sun.nio.fs.WindowsWatchService$WindowsWatchKey@ae7c53
{felix.fileinstall.poll (ms) = 2000, felix.fileinstall.dir = D:\HERLE\Data\iot-sdk\FelixLauncher\.\fileinstall, felix.fileinstall.log.level = 4, felix.fileinstall.bundles.new.start = tru
e, felix.fileinstall.tmpdir = .\tmp, felix.fileinstall.filter = null, felix.fileinstall.start.level = 0}

Please let me know how can one do this using bnd.bnd config file?


回答1:


Main thing to consider is configuration. If you are using external library or jar then you need to mention it as private package.

please find my sample bnd.bnd file.

Bundle-Name: ${project.artifactId}
Bundle-SymbolicName: ${project.artifactId}
Bundle-Description: Template-Bundle for developing an application
Bundle-Category: Application
Bundle-Copyright: 2017 (c) Herleraja@gmail.com
-dsannotations: *
-metatypeannotations: *
Private-Package: \
    com.jcraft,\
    com.jcraft.jsch,\
    com.jcraft.jsch.jce,\
    com.jcraft.jsch.jcraft,\
    com.jcraft.jsch.jgss,\
    com.jcraft.jzlib

I suggest you to use BndTools to edit the bnd.bnd file. you can install BndTools plugin to eclipse from BndTool Installation.

Select the packages that you need.

Note: Since it automatically does not install all the dependencies you need to add if any extra jars required. i.e I wanted to use jsch, which had a dependency on jzlib. So I added these two entries in pom.xml file.

<dependency>
    <groupId>com.jcraft</groupId>
    <artifactId>jsch</artifactId>
    <version>0.1.54</version>
</dependency>


<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jzlib</artifactId>
<version>1.1.3</version>
</dependency>

Hope this helps some! Please vote so that i can write more solution.



来源:https://stackoverflow.com/questions/49792223/bndtools-how-to-add-a-non-osgi-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!