1.5.9: Could not initialize class org.bytedeco.opencv.opencv_core.Mat
b005t3r opened this issue · 10 comments
I'm getting this random issue on some Windows 11 machines:
java.lang.NoClassDefFoundError: Could not initialize class org.bytedeco.opencv.opencv_core.Mat
not sure what might be causing it, as it only happens on some machines that I have no access to. I see there are some issues reported with broken dependencies in 1.5.9, but not this particular one.
Please try again with 1.5.10
Please try again with 1.5.10
Just tried it with 1.5.10, the issue is still there.
As I said, it's not consistent and happens only on some Windows 11 machines, no idea why.
What can I do to investigate it further?
Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.
OK, here are the results, I think the issue is pretty clear (missing OpenCV dependencies):
Debug: Failed to load for opencv_cudev490: java.lang.UnsatisfiedLinkError: no opencv_cudev490 in java.library.path: [C:\Program Files\Test App\data\jdk-13.0.2\bin, C:\windows\Sun\Java\bin, C:\windows\system32, C:\windows, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, C:\windows\System32\OpenSSH\, C:\Users\testuser\AppData\Local\Microsoft\WindowsApps, ., .]
Debug: Loading C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_core490.dll
Debug: Failed to load C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_core490.dll: java.lang.UnsatisfiedLinkError: C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_core490.dll: Can't find dependent libraries
Debug: Loading library opencv_core490
Debug: Failed to load for opencv_core490: java.lang.UnsatisfiedLinkError: no opencv_core490 in java.library.path: [C:\Program Files\Test App\data\jdk-13.0.2\bin, C:\windows\Sun\Java\bin, C:\windows\system32, C:\windows, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, C:\windows\System32\OpenSSH\, C:\Users\testuser\AppData\Local\Microsoft\WindowsApps, ., .]
Debug: Loading C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_imgproc490.dll
Debug: Failed to load C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_imgproc490.dll: java.lang.UnsatisfiedLinkError: C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\opencv_imgproc490.dll: Can't find dependent libraries
Debug: Loading library opencv_imgproc490
Debug: Failed to load for opencv_imgproc490: java.lang.UnsatisfiedLinkError: no opencv_imgproc490 in java.library.path: [C:\Program Files\Test App\data\jdk-13.0.2\bin, C:\windows\Sun\Java\bin, C:\windows\system32, C:\windows, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, C:\windows\System32\OpenSSH\, C:\Users\testuser\AppData\Local\Microsoft\WindowsApps, ., .]
Debug: Loading C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\jniopencv_core.dll
Debug: Failed to load C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\jniopencv_core.dll: java.lang.UnsatisfiedLinkError: C:\Users\testuser\.javacpp\cache\testapp.jar\org\bytedeco\opencv\windows-x86_64\jniopencv_core.dll: Can't find dependent libraries
Debug: Loading library jniopencv_core
Debug: Failed to load for jniopencv_core: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path: [C:\Program Files\Test App\data\jdk-13.0.2\bin, C:\windows\Sun\Java\bin, C:\windows\system32, C:\windows, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, C:\windows\System32\OpenSSH\, C:\Users\testuser\AppData\Local\Microsoft\WindowsApps, ., .]
I checked the opencv_core.dll file in DependenciesGui and got this:
For opencv_imgproc.dll those are missing:
No idea why was it linked against those VS libs?
It looks like the issue is easily fixable (I mean not fixable, but it's relatively easy workaround) by installing this:
https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version
Those are available with javacpp-platform
I don't understand. Is there another dependency I need to list in my pom.xml? I would really appreciate if you replied with a more elaborate explanation from time to time :)
The README.md says to use opencv-platform. If you're not using that, then don't expect things to work. What more do you need to know?
What you mean is that instead of doing this:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv</artifactId>
<version>4.9.0-1.5.10</version>
<scope>compile</scope>
<classifier>windows-x86_64</classifier>
</dependency>
I'm supposed to do this?
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv-platform</artifactId>
<version>4.9.0-1.5.10</version>
<scope>compile</scope>
<classifier>windows-x86_64</classifier>
</dependency>
I assumed that fixed it, but please let me know if that still doesn't work