Unable to Load Library 'virt': libvirt.so - java

I'm working on Ubuntu and using Netbeans. My code is trying to connect to the libvirt host "qemu+ssh://IPaddress/system". The development environment and the service environment is different. The output-jar file I put on the service environment but apparently I hit below error when rebooting the service. I already added the jna-3.2.5.jar and the libvirt-0.5.1.jar on to the path folder of my service environment.
Exception in thread "main" 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:164)
at com.sun.jna.Native.loadLibrary(Native.java:375)
at com.sun.jna.Native.loadLibrary(Native.java:360)
at org.libvirt.jna.Libvirt.<clinit>(Unknown Source)
at org.libvirt.Library.<clinit>(Unknown Source)
at org.libvirt.Connect.<init>(Unknown Source)
What else I have missed?

thanks for the response.
Apparently, I have to install libvirt package on to my service environment, and the error will be gone. I hope it will help other's problem as well.

Related

JCEF initialization issue on MacOS

My Java app which uses JCEF, works perfectly fine in Windows Operating System. But when I try to run this sample application on MacOS Mojave, then it's facing initialization issues. I have added the desired jars and JCEF MacOS libraries/binaries into my project, also added JVM parameter to startup configuration as:
-Djava.library.path=*/jcef/jcef_build/native/Release,
but at the time of running application im facing the folowing error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /jcef_build/native/Release/libjcef.dylib: dlopen(*/jcef_build/native/Release/libjcef.dylib, 1): Library not loaded: #rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework
Referenced from: */jcef_build/native/Release/libjcef.dylib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.cef.CefApp.<init>(CefApp.java:149)
at org.cef.CefApp.getInstance(CefApp.java:237)
at org.cef.CefApp.getInstance(CefApp.java:224)
at MainFrame.<init>(MainFrame.java:70)
at MainFrame.main(MainFrame.java:145)
Please any one suggest what I am missing in running this sample application.

Tomcat not running for a JAR file

I am using Postman alongside a JAR file that runs a REST service that holds some contacts. However when I try to run the JAR file by using: java -jar ContactListRESTService.jar in Powershell, I am seeing a bunch of errors that Apache Tomcat could not run. Postman also doesn't recognize the localhost.
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159)
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletCntainer.java:159) ~[spring-boot 1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
I have tried uninstalling and reinstalling JAVA SE per some guidance from a mentor with no results.
If anyone can point me in the right direction please.

Could not initialize class javax.crypto.SunJCE_b

I have a Java servlet application developed and on my develpment PC everything works as expected including using SFTP programmatically to copy over a PDF using HTTPS on port 8443 etc and with SSL certificates in place too.
However, when I attempt to run the application on the Live server I receive the error;
java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.SunJCE_b
On investigation, some are suggesting check the jce.jar. But I have ensured the jce.jar is present and also created a "lib" folder in my project and copied the jar there and placed the jar on my build path but still the problem exists.
How do I resolve this please? Thanks in advance. Here is the console output from right after Tomcat has started the application;
#
08-Jan-2014 10:45:44 org.apache.catalina.startup.Catalina start
INFO: Server startup in 12715 ms
08-Jan-2014 10:47:42 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor run
SEVERE:
java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.SunJCE_b
at javax.crypto.Cipher.getInstance(DashoA13*..)
at com.sun.net.ssl.internal.ssl.JsseJce.getCipher(Unknown Source)
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(Unknown Source)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.net.ssl.internal.ssl.Handshaker$DelegatedTask.run(Unknown Source)
at org.apache.tomcat.util.net.SecureNioChannel.tasks(SecureNioChannel.java:285)
at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap
(SecureNioChannel.java:343)
at org.apache.tomcat.util.net.SecureNioChannel.handshake
(SecureNioChannel.java:193)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run
(NioEndpoint.java:1642)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The jce.jar must be inside the folder WEB-INF/lib of the deployed web application.
I've seen this problem pop up very often and there seems to be a lot of confusion around it. The actual reason this is happening is because the JRE you are using to run your application has been set up with the unrestricted JCE policy jars inside its jre/lib folder (inside your jdk install folder).
If your current project does not need these, then you can move then out of this folder temporarily. This will remove the requirement on the jce libraries and you will no longer see this error.
Hope this helps.

Open an eml file with java in linux

I am trying to open my created .eml file with java in linux. Currently I am using the following command:
Desktop.getDesktop().open(emlFile);
I create the eml file as shown in this example.
This works for my windows system, but an error occurs in linux ubuntu 12.04.
EDIT: error message:
(process:19386): gnome-vfs-modules-WARNING **: Could not initialize inotify
java.io.IOException: Failed to show URI:file:/home/usr/workspace/programm/eml/mail.eml
at sun.awt.X11.XDesktopPeer.launch(Unknown Source)
at sun.awt.X11.XDesktopPeer.open(Unknown Source)
at java.awt.Desktop.open(Unknown Source)
I am happy for any help!
From the docs java.awt.Desktop.open(File)
Throws IOException - if the specified file has no associated
application or the associated application fails to be launched

How to proceed with this exception java.lang.UnsatisfiedLinkError?

this example of code generates an exception :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-win32-3235 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:134)
at org.eclipse.swt.internal.win32.OS.<clinit>(OS.java:18)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:125)
at Snippet262.main(Snippet262.java:34)
What does it mean please and how can I resolve it ?
Thank you
You need to add swt-win32-3235.dll to the library_path in your app. By default library_path equals to working dir (".") of your app. Or you may specify path to library_path in vm argument -Djava.library.path=path
So,
1.Check existing swt-win32-3235.dll in your library_path.
2. Check correct definition of library_path property.
This is a runtime exception, that means that the code uses shared library's (using jni probably) which it cannot load.
here you have two options:
the shared library is not installed on you system.
the path to the shared lib is not included in the LD_LIBRARY_PATH (on linux, not sure how it called on windows)
I got the error while running my application. The exception was
java.lang.UnsatisfiedLinkError exception :
SK.gnome.twain.TwainManager.initialize(I[B[BZ)V
I fix it in eclipse as below step, Windows>Preferences>Java>Install JREs>check jre6-32 (check the appropriate versions of jre that you have install in your system).

Categories

Resources