jnidispatch.dll 使用 gluonfx 编译为本机后未在资源路径中找到
jnidispatch.dll not found in resource path after compile to native with gluonfx
我正在使用 gluonfx 插件编译为本机 javafx 应用程序。
为了执行一些网络功能,我需要添加一些 pcap 依赖项,我在调试模式下进行了测试,一切正常。但是在编译为本机后,当我尝试使用已实现的函数时出现以下错误:
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.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(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(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(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(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
失败的代码:
var service = Service.Creator.create("PcapService"); **//This line throws the exception**
for (Interface device : service.interfaces()) {
...
}
已添加依赖项:
<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>
提前致谢!
在@JosePereda 的评论后解决。
通过 运行 宁 mvn gluonfx:runagent
必要的配置自动添加到 resources/META-INF.nativeimages/ 文件。
之后用 mvn gluonfx:build
和应用程序 运行 再次编译成功,我能够查询该函数。
@JosePereda 再次感谢破解!
我正在使用 gluonfx 插件编译为本机 javafx 应用程序。 为了执行一些网络功能,我需要添加一些 pcap 依赖项,我在调试模式下进行了测试,一切正常。但是在编译为本机后,当我尝试使用已实现的函数时出现以下错误:
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.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(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(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(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(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
失败的代码:
var service = Service.Creator.create("PcapService"); **//This line throws the exception**
for (Interface device : service.interfaces()) {
...
}
已添加依赖项:
<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>
提前致谢!
在@JosePereda 的评论后解决。
通过 运行 宁 mvn gluonfx:runagent
必要的配置自动添加到 resources/META-INF.nativeimages/ 文件。
之后用 mvn gluonfx:build
和应用程序 运行 再次编译成功,我能够查询该函数。
@JosePereda 再次感谢破解!