Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path running two Java VM's on the same Windows Server #48

Closed
michelriondel opened this issue Oct 29, 2019 · 3 comments

Comments

@michelriondel
Copy link

Hi

We use your Maven Project and it runs very well.
We use the Maven Project:

org.openpnp
opencv
3.2.0-0

And Initialize the OpenCV Libraries like that
/**

  • Load the OpenCV Library once static
    */
    static {
    nu.pattern.OpenCV.loadShared();
    }

From the documentation on the github mainpage I understand, that when the vm starts it copies the libraries to some temp location.
Could it be that if we start two Java VM's on the same Windows Server that there is some overriding? Or is there any other restriction?

Basically the stacktrace we get is:
2019-10-28 12:48:31,654 ERROR ch.helsana.unifygate.consumer.GenericConsumer [pool-1-thread-2] APP1_20190813_01469153: error on process -
ch.helsana.unifygate.processor.ProcessorException: java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path
at ch.helsana.unifygate.processor.AdaptiveThresholdProcessor.process(AdaptiveThresholdProcessor.java:115)
at ch.helsana.unifygate.consumer.GenericConsumer.consume(GenericConsumer.java:35)
at ch.helsana.unifygate.consumer.AbstractConsumer.run(AbstractConsumer.java:93)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at nu.pattern.OpenCV$SharedLoader.(OpenCV.java:204)
at nu.pattern.OpenCV$SharedLoader.(OpenCV.java:185)
at nu.pattern.OpenCV$SharedLoader$Holder.(OpenCV.java:225)
at nu.pattern.OpenCV$SharedLoader.getInstance(OpenCV.java:229)
at nu.pattern.OpenCV.loadShared(OpenCV.java:179)
at ch.helsana.unifygate.utils.ImageUtils.(ImageUtils.java:33)
at ch.helsana.unifygate.processor.AdaptiveThresholdProcessor.createAdaptiveThresholdFile(AdaptiveThresholdProcessor.java:161)
at ch.helsana.unifygate.processor.AdaptiveThresholdProcessor.process(AdaptiveThresholdProcessor.java:82)
... 5 common frames omitted

Any help on how to run multiple VM's on the same server would help.

Regards Michel Riondel

@michelriondel
Copy link
Author

Hi there

short update from my side.. If we copy the jar file that includes opencv to two locations and run those separate jar files we don't get any issues. I guess that is as described solving the temp directory problem.

regards Michel Riondel

@vonnieda
Copy link
Member

vonnieda commented Nov 5, 2019

Thanks for the report @michelriondel. I bet that what is happening is that https://github.com/openpnp/opencv/blob/develop/src/main/java/nu/pattern/OpenCV.java#L377 causes the second instance to delete the files from the first. I hope to switch to a better native library loader in the future (#44 (comment)) and hopefully that would resolve this as well.

@vonnieda
Copy link
Member

Please try the latest version and re-open if this is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants