javacv
javacv copied to clipboard
UnsatisfiedLinkError - jniavutil.dll - Cannot access the file. The file is being used by another process.
I am trying to use JavaCV in a JavaFX running in OSGi container.
The bundle that is using JavaCV as dependency is resolved correctly, but once started it creates an instance of org.bytedeco.javacv.FFmpegFrameGrabber and I see this exception:
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: java.io.FileNotFoundException: C:\Users\andrea\.javacpp\cache\windows-x86_64\jniavutil.dll (**Impossibile accedere al file. Il file è utilizzato da un altro processo**) [in thread "JavaFX Application Thread"]
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1853)
at org.bytedeco.javacpp.Loader.load(Loader.java:1423)
at org.bytedeco.javacpp.Loader.load(Loader.java:1234)
at org.bytedeco.javacpp.Loader.load(Loader.java:1210)
at org.bytedeco.ffmpeg.avutil.AVChannelLayout.<clinit>(AVChannelLayout.java:46)
at org.bytedeco.ffmpeg.global.avutil.AV_CHANNEL_LAYOUT_MONO(Native Method)
at org.bytedeco.ffmpeg.global.avutil.<clinit>(avutil.java:4381)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:495)
at java.base/java.lang.Class.forName(Class.java:474)
at org.bytedeco.javacpp.Loader.load(Loader.java:1289)
at org.bytedeco.javacpp.Loader.load(Loader.java:1234)
at org.bytedeco.javacpp.Loader.load(Loader.java:1226)
at org.bytedeco.javacv.FFmpegFrameGrabber.tryLoad(FFmpegFrameGrabber.java:111)
at org.bytedeco.javacv.FFmpegFrameGrabber.<clinit>(FFmpegFrameGrabber.java:137)
... 23 more
The error message is in italian, but it says:
C:\Users\andrea\.javacpp\cache\windows-x86_64\jniavutil.dll (Cannot access the file. The file is being used by another process)
I checked that the file exists at that path and the only process that is using it is the Java application itself.
I embedded all the JavaCV jar files in the bundle and added all of them to the Bundle-ClassPath. I included only the jars for the windows-x86_64 platform. Here is the list of jars that I included.
artoolkitplus.jar
artoolkitplus-windows-x86_64.jar
ffmpeg.jar
ffmpeg-windows-x86_64.jar
flandmark-1.07-1.5.8.jar
flycapture.jar
flycapture-windows-x86_64.jar
javacpp.jar
javacpp-windows-x86_64.jar
javacv.jar
leptonica.jar
leptonica-windows-x86_64.jar
libdc1394.jar
libdc1394-windows-x86_64.jar
libfreenect.jar
libfreenect-windows-x86_64.jar
libfreenect2.jar
libfreenect2-windows-x86_64.jar
librealsense.jar
librealsense-windows-x86_64.jar
librealsense2.jar
librealsense2-windows-x86_64.jar
openblas.jar
openblas-windows-x86_64.jar
opencv.jar
opencv-windows-x86_64.jar
tesseract.jar
tesseract-windows-x86_64.jar
videoinput.jar
videoinput-windows-x86_64.jar
Environment details:
- Windows 10
- Java 19
- JavaCV 1.5.9
Does this happen only with OSGi? If so, please try again with an "uber JAR".
I think you're saying you're already using an uber JAR? If so, try other combinations, with/without OSGi, with/without JavaFX, with/without Java SE 8, etc. Let's which ones work, which ones don't.
I think you're saying you're already using an uber JAR? If so, try other combinations, with/without OSGi, with/without JavaFX, with/without Java SE 8, etc. Let's which ones work, which ones don't.
Yes, the dependencies are packaged inside the jar bundle. I also tried with a non-OSGi JavaFX application and everything works perfectly.
So it's some OSGi related bug... BTW, why are you running this as admin? And are you sure the home directory is a local drive and not remotely mounted or something?
So it's some OSGi related bug... BTW, why are you running this as admin? And are you sure the home directory is a local drive and not remotely mounted or something?
I am running this on a local drive. Don't mind the admin username you see in the paths. It's not the real username I am using.
Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console.