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\admin\.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\admin\.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