简体   繁体   English

libvirt的不满意的链接错误

[英]Unsatisfied link error for libvirt

I am trying to connect kvm through java using the code present at 我正在尝试使用以下代码通过Java连接kvm

https://libvirt.org/java.html https://libvirt.org/java.html

When I try to connect i receive the below error 当我尝试连接时,出现以下错误

2016-04-23 21:18:17.960 ERROR 6359 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.UnsatisfiedLinkError: Unable to load library 'virt': libvirt.so: cannot open shared object file: No such file or directory] with root cause

java.lang.UnsatisfiedLinkError: Unable to load library 'virt': libvirt.so: cannot open shared object file: No such file or directory
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166) ~[jna-3.3.0.jar!/:3.3.0 (b0)]
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239) ~[jna-3.3.0.jar!/:3.3.0 (b0)]
    at com.sun.jna.Library$Handler.<init>(Library.java:140) ~[jna-3.3.0.jar!/:3.3.0 (b0)]
    at com.sun.jna.Native.loadLibrary(Native.java:393) ~[jna-3.3.0.jar!/:3.3.0 

I have libvirt installed on ubuntu 我在Ubuntu上安装了libvirt

 libvirtd --version
libvirtd (libvirt) 1.2.2

And my build.gradle is 我的build.gradle是

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.libvirt:libvirt:0.5.1')
    compile('net.java.dev.jna:jna:3.3.0')
    testCompile('org.springframework.boot:spring-boot-starter-test') 
}

Has anyone faced similar issue. 有没有人遇到过类似的问题。

since you are on linux this exception is thrown when your application attempts to load a native library like .so .in this case JVM is looking in both the PATH environment variable and the java.library.path system property. 由于您使用的是Linux,因此当您的应用程序尝试加载.so这样的本机库时,将抛出此异常。在这种情况下,JVM会同时在PATH环境变量和java.library.path系统属性中查找。 .to fix this exception you need to set path for that library u are trying to load. 要修复此异常,您需要为您要加载的库设置路径。 just like you set path for java. 就像您为java设置路径一样。

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

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