简体   繁体   English

找不到OSGI JNA本机库pcap

[英]OSGI JNA native library pcap not found

I'm using pcap4j in my OSGI project. 我在OSGI项目中使用pcap4j The devices the application is running on is running openembedded. 运行应用程序的设备正在运行openembedded。 When I'm running my code in a standalone application (non OSGI) on a device, it works without problem. 当我在设备上的独立应用程序(非OSGI)中运行代码时,它可以正常工作。 When running inside an OSGI it doesn't. 在OSGI中运行时,不是这样。 I embedded the pcap4j dependencies as they are not bundles. 我嵌入了pcap4j依赖项,因为它们不是捆绑包。 The manifest contains the import of com.sun.jna and the bundle jna 4.2.0 is available (and used by another bundle). 清单包含com.sun.jna的导入,并且捆绑包jna 4.2.0可用(并由另一个捆绑包使用)。 I also tried by calling System.load and System.loadLibrary... 我也尝试通过调用System.load和System.loadLibrary ...

I've got the same problem too and I made an osgi bundle for pcap4j and its dependents. 我也遇到了同样的问题,我为pcap4j及其附属程序制作了一个osgi软件包。 Here's the jar files in the bundle: 这是捆绑软件中的jar文件:

jna-4.2.1.jar, 
pcap4j-core-1.7.3.jar, 
pcap4j-packetfactory-static-1.7.3.jar,
slf4j-api-1.7.12.jar, 
slf4j-nop-1.6.2.jar

The entire MANIFEST.MF file: 整个MANIFEST.MF文件:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pcap4j
Bundle-SymbolicName: pcap4j
Bundle-Version: 1.0.0
Bundle-ClassPath: jna-4.2.1.jar, pcap4j-core-1.7.3.jar, pcap4j-packetfactory-static-1.7.3.jar, slf4j-api-1.7.12.jar, slf4j-nop-1.6.2.jar
Export-Package: com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32,org.pcap4j,org.pcap4j.core,org.pcap4j.packet,org.pcap4j.packet.constant,org.pcap4j.packet.factory,org.pcap4j.packet.namednumber,org.pcap4j.util,org.slf4j,org.slf4j.helpers,org.slf4j.impl,org.slf4j.spi
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

After that you can simply use these packages using Import-Package. 之后,您可以简单地使用Import-Package使用这些软件包。

Import-Package: org.osgi.framework;version="1.3.0", org.pcap4j.core, org.pcap4j.packet, org.pcap4j.packet.namednumber

Also look at this issue on pcap4j repository to more information. 另请参阅pcap4j存储库上的此问题以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM