org.usb4java.LoaderException: Native library not found in classpath error - java

Am an trying to use the usb4java library with a project running in Ubuntu 64bit. I am getting the following error;
30 Jul 2015 09:46:16,225 INFO Controller : Working Directory: /opt/dock
Exception in thread "main" java.lang.ExceptionInInitializerError
at uk.co.swimtag.control.Controller.findDevice(Controller.java:755)
at uk.co.swimtag.control.Controller.startApplication(Controller.java:150)
at uk.co.swimtag.control.Controller.main(Controller.java:104)
Caused by: org.usb4java.LoaderException: Native library not found in classpath: /org/usb4java/linux-x86_64/libusb4java.so
at org.usb4java.Loader.extractLibrary(Loader.java:281)
at org.usb4java.Loader.load(Loader.java:358)
at org.usb4java.LibUsb.<clinit>(LibUsb.java:640)
... 3 more
Here are the two jars in the manifest file, and am sure the x86_64 lib is in the project;
lib/mail.jar
lib/gson-1.6.jar
lib/usb4java-1.2.0.jar
lib/libusb4java-1.2.0-linux-x-86_64.jar
conf/
Any one had similar problems with usb4java. Probably something silly I have missed.
Thanks

Maybe it is just a typo. But if you're sure the jar with natives is on your CLASSPATH, it may be that in your manifest file you wrote: libusb4java-1.2.0-linux-x-86_64.jar instead of libusb4java-1.2.0-linux-x86_64.jar

Related

How to get KQueue to be available in Java in OSX?

My packages are as following:
implementation("io.netty:netty-transport-native-epoll:$nettyVersion")
implementation("io.netty:netty-transport-native-kqueue:$nettyVersion")
implementation("io.netty:netty-transport-native-epoll:$nettyVersion:linux-aarch_64")
implementation("io.netty:netty-transport-native-epoll:$nettyVersion:linux-x86_64")
implementation("io.netty:netty-transport-native-kqueue:$nettyVersion:osx-x86_64")
Gradle showing the package getting installed correctly: (where <source> is the path to our internal library storage)
Cached resource <source>/releases/io/netty/netty-transport-native-kqueue/4.1.78.Final/netty-transport-native-kqueue-4.1.78.Final-osx-x86_64.jar is up-to-date (lastModified: Fri Jun 24 17:45:28 PDT 2022).
Gradle output showing the system:
------------------------------------------------------------------------
Detecting the operating system and CPU architecture
------------------------------------------------------------------------
os.detected.name=osx
os.detected.arch=x86_64
os.detected.version=12.4
os.detected.version.major=12
os.detected.version.minor=4
os.detected.classifier=osx-x86_64
Simplest way I can reproduce is:
KQueue.isAvailable()
returns false.
If I run the following to get more information:
KQueue.unavailabilityCause().printStackTrace();
I get: (removed repeating or unnecessary stack traces)
java.lang.UnsatisfiedLinkError: could not load a native library: netty_transport_native_kqueue_x86_64
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239)
at io.netty.channel.kqueue.Native.loadNativeLibrary(Native.java:155)
...
Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_kqueue_x86_64 in java.library.path: /Users/kdilsiz/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
...
Am I not supposed to be able to run this code? What am I missing?
If I search online for the error, it shows outdated Netty package loading errors (only showing up in debug level logging). This is NOT my problem. The package loads correctly when I run gradle and I can see it is being cached/loaded with gradle -info --refresh-dependencies.
It was due to one of the dependencies importing netty-all. This was causing the Kqueue packages to be imported twice and with different versions.
The problem was that I did not fully read the stack trace from:
KQueue.unavailabilityCause().printStackTrace();
In the end of that stack trace, it said:
Caused by: java.lang.IllegalStateException: Multiple resources found for 'META-INF/native/libnetty_transport_native_kqueue_x86_64.jnilib' with different content:
...
After that, I was able to find where the package was coming from and fix it. Then I was able to locally run the Java Code to run domain socket and test it locally.
I used IntelliJ to run it after the fix. (VsCode had a problem even after the fix, hence wanted to mention it)

MysqldResource isn't working with MacOS Catalina

Since upgrading my os to Mac Catalina,
I'm getting the following error when trying to run the following:
MysqldResource mysqldResource = new MysqldResource(uri); // Uri - temp db dir
mysqldResource.start("embedded-mysqld-thread-" + System.currentTimeMillis(), databaseOptions);
Looks like the source of the problem is with the dependency "mysql-connector-mxj-db-files" having binary files in 32bit format, while catalina stopped supporting it.
This is the error I'm getting:
Exception in thread "embedded-mysqld-thread-1574931580040" com.mysql.management.util.WrappedException: java.io.IOException: Cannot run program "/private/var/folders/l5/4ywgvbbj1kvgvrwxzp6dz82c0000gn/T/test_db_24166997810717/bin/mysqld": error=86, Bad CPU type in executable
at com.mysql.management.util.Exceptions.toRuntime(Exceptions.java:55)
at com.mysql.management.util.Exceptions$Block.exec(Exceptions.java:89)
at com.mysql.management.util.RuntimeI$Default.exec(RuntimeI.java:180)
at com.mysql.management.util.Shell$Default.run(Shell.java:140)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Cannot run program "/private/var/folders/l5/4ywgvbbj1kvgvrwxzp6dz82c0000gn/T/test_db_24166997810717/bin/mysqld": error=86, Bad CPU type in executable
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at com.mysql.management.util.RuntimeI$Default$1.inner(RuntimeI.java:177)
at com.mysql.management.util.Exceptions$Block.exec(Exceptions.java:86)
... 3 more
Caused by: java.io.IOException: error=86, Bad CPU type in executable
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 6 more
Does anyone know of an alternative to mysql-connector-java or knows of a way to run the existing dependency on Mac OS Catalina?
For anyone who has the same issue on MacOS Catalina, you can follow the README.md in my repo (https://github.com/pengyue/mysql-connector-mxj-mac-os-catalina), which has the 64 bits executables for MacOS Catalina, and this improved connector works on Catalina.
To explain what I have done:
Download the 64 bits executables from MySQL to the folder 5-5-9
Add the platform mapping for 64 bits MacOS in platform-map.properties
Create a jar by using jar cvf mysql-connector-mxj-db-files-5.0.12.jar .
Replace the jar in your mvn settings folder ~/.m2/repository/mysql/mysql-connector-mxj-db-files/5.0.12/ with the jar you just created.
This solution works fine for my projects, Unfortunately I could not find a github for the mysql-connector-mxj, as it is deprecated and not maintainable anymore.
The other option is to use wix-embedded-mysql(https://github.com/wix/wix-embedded-mysql) instead of mysql-connector-mxj, but this probably requires some code changes in your projects.

Failed startup of context c.g.g.d.s.j.WebAppContextWithReload

I need help with an issue I have no idea how to resolve. Your help will be greatly appreciated.
I just added log4j2 jars (log4j-api-2.10.0.jar, log4j-core-2.10.0.jar) to my Web app and it started running into this problem in my dev. Later I added log4j-web-2.10.0.jar and tried, it still fails with the same message.
Here's my environment:
IDE: Eclipse Oxygen2
JDK: 1.8.0_162
Jetty (embedded in Eclipse): jetty-9.2.z-SNAPSHOT
OS: Win 10 (64bit)
Framework: GWT 2.8.2
Stack trace (partial):
[WARN] Failed startup of context c.g.g.d.s.j.WebAppContextWithReload#3a24f397{/,file:<project_path>/war/,STARTING}{<project_path>\war}
MultiException[java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class from jar file:<project_path>/war/WEB-INF/lib/log4j-api-2.10.0.jar, java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class from jar file:<project_path>/war/WEB-INF/lib/log4j-api-2.10.0.jar, java.lang.RuntimeException: Error scanning entry module-info.class from jar file:<project_path>/war/WEB-INF/lib/log4j-api-2.10.0.jar]
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:536)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:447)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:479)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1337)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
.
.
.
Caused by: MultiException[java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class from jar file:<project_path>/WEB-INF/lib/log4j-api-2.10.0.jar, java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class from jar file:<project_path>/WEB-INF/lib/log4j-api-2.10.0.jar, java.lang.RuntimeException: Error scanning entry module-info.class from jar file:<project_path>/WEB-INF/lib/log4j-api-2.10.0.jar]
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:899)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:831)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:548)
Copied from https://github.com/eclipse/jetty.project/issues/2192, (with additional edits)
This is related to your use of a JEP-238 Multi-Release JAR.
Notice the path ..
META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class
The META-INF/versions/<java.specification.version>/* path prefix tells you that the classes below that path are for that specific version of Java, replacing potentially the same named classes in the top level JAR.
Issue #1797 is where this was first reported and fixed.
It was fixed for ...
jetty-9.3.22.v20171030 - 30 October 2017
jetty-9.4.8.v20171121 - 21 November 2017
Since Jetty 9.2.x is end of life, there will be no backport to support JEP-238 on Jetty 9.2.x.
Your choices are to upgrade to one of the supported versions listed above, or downgrade your version of log4j to one that does not use JEP-238 Multi-Release JAR Files.
Also of note, the log4j JEP-238 Multi-Release JAR file you are using is also a Java 9 JPMS module.
The presence module-info.class indicates that.
Support in Jetty to ignore module-info.class during bytecode scanning was fixed in Issue #1692

Unity-Android _ CommandInvokationFailure: Unable to convert classes into dex format

i'm using Windows 7, jdk 1.8.0 (64bit), jre 8 (64bit), Unity Pro 4.3.4f1 and Android SDK 22.6.1
All are updated softwares.
All works fine but when i use StartApp sdk, this error comes. No extra plugin is used, only the SDK provided by the StartApp ad.
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/android-sdks\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/a$1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:129)
1 error; aborting
]
I already tried JAVA_OPT and JAVA_HOME solutions. But still couldn't solved
I ran into this using IntelliJ 13.1.4, JDK 1.6 but I would guess that this is caused by the same thing on any other IDE -> classes.jar is referenced/included more than once.
Check and make sure that the classes.jar you added to the project (from Unity\Editor\Data\PlaybackEngines\androidplayer\bin\classes.jar) isn't referenced/included more than once. If you go into File->Project Structure:
There should only be one "classes" under libraries.
There should be NO reference to classes under Artifacts (Artifacts is used to create the plugin .jar file.)
Check out this related answer ->
https://stackoverflow.com/a/8437996/3464367
My issue was actually related to having duplicate files. Well not really duplicates, but I had 2 adMob sdk packages (different versions), that were getting into conflict. After deleting the older one, everything was fixed. Are you using any 3rd party SDK's or something similar, if so, try removing them if possible and see if the issue persists. Try to find out which part of the code is causing this to happen. You could ultimately try to compile an empty project just for testing.
Today I solved similar problem of Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. with adding .jar file into Plugins\Android\
I got different kind of errors:
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000 ...
Caused by: com.android.dx.cf.iface.ParseException: class name (ht/stringing/test) does not match path (src/ht/stringing/test.class)
My result working solution was similar to this:
Code lives here:
verysimple\src\ht\stringing\test.java
I do:
> javac -classpath "c:\Android\sdk\platforms\android-15" ht\stringing\test.java
> jar cvf ..\dist\verysimple.jar ht\stringing\test.class
> copy ..\dist\verysimple.jar c:\ExUnityApp\Assets\Plugins\Android
Don't forget to compare your 'Minimum Api Level' in Player Setting. For me it was Android 4.0.3 ... (15)

Cannot run Xuggler on linux

I have a problem running Xuggler on linux:
08:43:05.550 [main] WARN com.xuggle.ferry.JNILibrary - Failure: library load of library: xuggle; url: /tmp/xuggle/xuggle2624685369771797713.tmp; error: java.lang.UnsatisfiedLinkError: /tmp/xuggle/xuggle2624685369771797713.tmp: /tmp/xuggle/xuggle2624685369771797713.tmp: failed to map segment from shared object: Operation not permitted
08:43:05.565 [main] ERROR com.xuggle.ferry.JNILibraryLoader - Could not load library: xuggle; version: 5; Visit http://www.xuggle.com/xuggler/faq/ to find common solutions to this problem
Exception in thread "main" java.lang.UnsatisfiedLinkError: no xuggle in java.library.path
Same JAR works fine on Windows.
I tried to include xuggler-5.4.jar, 5.2.jar, I also tried to make maven project and to compile with maven, the problem persists.
Here is the CLASSPATH, so you can see I also included lately in the classpath the jar
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64//jre/lib/ext:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64//lib/tools.jar:/home/baidoc/libs/xuggle-xuggler-5.4.jar

Categories

Resources