简体   繁体   English

使用 gluonfx 编译为本机后,在资源路径中找不到 jnidispatch.dll

[英]jnidispatch.dll not found in resource path after compile to native with gluonfx

I'm compiling to native a javafx app using gluonfx plugin.我正在使用 gluonfx 插件编译为本机 javafx 应用程序。 To perform some.network functions I needed to add some pcap dependencies, I tested in debug mode and everything goes fine.为了执行一些网络功能,我需要添加一些pcap依赖项,我在调试模式下进行了测试,一切正常。 But after compile to native I have the following error when I try to use the implemented function:但是在编译为本机后,当我尝试使用已实现的 function 时出现以下错误:

Exception in thread "JavaFX Application Thread" java.util.ServiceConfigurationError: pcap.spi.Service: Provider pcap.jdk7.internal.DefaultService could not be instantiated
     at java.util.ServiceLoader.fail(ServiceLoader.java:582)
     at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:804)
     at java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)
     at java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
     at pcap.spi.Service$Creator.<clinit>(Service.java:343)
     at [project path].VdsConfiguratorService.getNetworkInterfaces(VdsConfiguratorService.java:27)
     at [project path].vdsswitchconfig.VdsSwitchConfigurator.<init>(VdsSwitchConfigurator.java:20)
     at [project path].GuiExtraStarter.show(GuiExtraStarter.java:84)
     at [project path].FxMainMenu.lambda$updateContent$7(FxMainMenu.java:80)
     at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
     at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
     at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
     at javafx.event.Event.fireEvent(Event.java:198)
     at javafx.scene.control.MenuItem.fire(MenuItem.java:459)
     at com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1385)
     at com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.lambda$createChildren$12(ContextMenuContent.java:1338)
     at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
     at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
     at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
     at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
     at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
     at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
     at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
     at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
     at javafx.event.Event.fireEvent(Event.java:198)
     at javafx.scene.Scene$MouseHandler.process(Scene.java:3881)
     at javafx.scene.Scene.processMouseEvent(Scene.java:1874)
     at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2607)
     at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
     at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
     at java.security.AccessController.doPrivileged(AccessController.java:107)
     at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
     at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
     at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
     at com.sun.glass.ui.View.handleMouseEvent(View.java:551)
     at com.sun.glass.ui.View.notifyMouse(View.java:937)
     at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_View_notifyMouse_4f1a8388c3763e6ef91b5795c9a3bb669af40a28(JNIJavaCallWrappers.java:0)
     at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
     at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
     at java.lang.Thread.run(Thread.java:829)
     at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597)
     at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:140)
Caused by: java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/win32-x86-64/jnidispatch.dll) not found in resource path ()
     at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1033)
     at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:989)
     at com.sun.jna.Native.<clinit>(Native.java:195)
     at com.sun.jna.Structure.setAlignType(Structure.java:291)
     at com.sun.jna.Structure.<init>(Structure.java:208)
     at com.sun.jna.Structure.<init>(Structure.java:204)
     at com.sun.jna.Structure.<init>(Structure.java:191)
     at com.sun.jna.Structure.<init>(Structure.java:183)
     at pcap.jdk7.internal.NativeMappings$ErrorBuffer.<init>(NativeMappings.java:734)
     at pcap.jdk7.internal.NativeMappings$ErrorBuffer.<init>(NativeMappings.java:731)
     at pcap.jdk7.internal.DefaultService.<init>(DefaultService.java:33)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:490)                                                                                           
     at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:780)
     ... 51 more     

Code that fails:失败的代码:

var service = Service.Creator.create("PcapService"); **//This line throws the exception**
for (Interface device : service.interfaces()) {
  ...
}

Dependencies added:添加的依赖项:

<dependencyManagement>
  <dependencies>     
     <dependency>
        <groupId>com.ardikars.pcap</groupId>
        <artifactId>pcap</artifactId>
        <version>1.4.1</version>
        <type>pom</type>
        <scope>import</scope>
     </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
   <dependency>
       <groupId>com.ardikars.pcap</groupId>
       <artifactId>pcap-jdk7</artifactId>
   </dependency>
</dependencies>

Thanks in advance!提前致谢!

Solved after comment of @JosePereda.在@JosePereda 发表评论后解决。

By running mvn gluonfx:runagent the necessary configuration was automatically added to resources/META-INF.nativeimages/ files.通过运行mvn gluonfx:runagent ,必要的配置会自动添加到resources/META-INF.nativeimages/文件中。 After that compiled again with mvn gluonfx:build and the app run successfully and I was able to query the function.之后用mvn gluonfx:build再次编译,应用程序成功运行,我能够查询 function。

@JosePereda Thanks one more time crack! @JosePereda 再次感谢您!

暂无
暂无

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

相关问题 UnsatisfiedLinkError-本机库-jnidispatch.dll - UnsatisfiedLinkError - Native Library - jnidispatch.dll 在资源路径中找不到线程“主” java.lang.UnsatisfiedLinkError中的异常:jnidispatch(/ com / sun /jna/win32-x86/jnidispatch.dll) - Exception in thread “main” java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun /jna/win32-x86/jnidispatch.dll) not found in resource path 在资源路径中找不到本机库 - native library not found in resource path UnsatisfiedLinkError - 无法加载库 - 在资源路径中找不到本机库 - UnsatisfiedLinkError - Unable to load library - Native library not found in resource path 尝试在Mac OS X上加载JNA库时出现“无法加载库:在资源路径中找不到JNA本机支持” - “Unable to load library: JNA native support not found in resource path” on trying to load JNA library on Mac OS X 在资源路径中找不到本机库(linux-x86-64 / libtesseract.so) - Native library (linux-x86-64/libtesseract.so) not found in resource path 找不到类路径资源 - Class path resource not found randomly 在资源路径中找不到本机库(com / sun / jna / android-aarch64 / libjnidispatch.so) - Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path 在资源路径中找不到 JNA 原生支持 (/com/sun/jna/linux-arm/libjnidispatch.so) - JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path 为Netbeans中的本机dll提供自定义路径 - Giving custom path for native dll in Netbeans
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM