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

Error "Failed to get field handle to set library path" when using Java 12 #44

Closed
martinschneider opened this issue Apr 25, 2019 · 7 comments
Closed

Comments

@martinschneider
Copy link

@martinschneider martinschneider commented Apr 25, 2019

When calling OpenCV.loadShared();:

java.lang.ExceptionInInitializerError
	at nu.pattern.OpenCV$SharedLoader.getInstance(OpenCV.java:232)
	at nu.pattern.OpenCV.loadShared(OpenCV.java:181)

Caused by: java.lang.RuntimeException: Failed to get field handle to set library path
	at nu.pattern.OpenCV$SharedLoader.addLibraryPath(OpenCV.java:258)
	at nu.pattern.OpenCV$SharedLoader.<init>(OpenCV.java:206)
	at nu.pattern.OpenCV$SharedLoader.<init>(OpenCV.java:187)
	at nu.pattern.OpenCV$SharedLoader$Holder.<clinit>(OpenCV.java:228)

I think the problem lies in this line but I'm not entirely sure how to fix it.

Is this a known issue?

@vonnieda
Copy link
Member

@vonnieda vonnieda commented May 10, 2019

Hi @martinschneider, no, this isn't a known problem. This library tends to be a little bit fragile when it comes to new Java versions, so there is probably some tweaks that need to be made. If you are able to come up with a compatible fix that would be very welcome! Otherwise, I will look at this as soon as I have some time.

Thanks,
Jason

@Maurice-Mueller
Copy link

@Maurice-Mueller Maurice-Mueller commented Jun 10, 2019

The same error for me. When I'm testing with OpenJDK 10 it is loading but I get the following warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by nu.pattern.OpenCV$SharedLoader (file:/home/maurice/.gradle/caches/modules-2/files-2.1/org.openpnp/opencv/3.4.2-1/fbd8f36fd1ce4e2bf0dcb12befd7d4cfc74d8d35/opencv-3.4.2-1.jar) to field java.lang.ClassLoader.usr_paths
WARNING: Please consider reporting this to the maintainers of nu.pattern.OpenCV$SharedLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/opencv_openpnp2599240055310010051/nu/pattern/opencv/linux/x86_64/libopencv_java342.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.

@rlking
Copy link

@rlking rlking commented Jun 21, 2019

Instead of OpenCV.loadShared(); you can use OpenCV.loadLocally(); if it's appropriate for your project. In JDK10+ they restricted the reflective access so it won't work anymore.

@AuligPromotions
Copy link

@AuligPromotions AuligPromotions commented Jul 10, 2019

I get the same error on Java 11.0.3. Problem is I need to use Java 11, so any ideas on how to fix this?

@vonnieda
Copy link
Member

@vonnieda vonnieda commented Jul 15, 2019

I have some changes in the works that will hopefully solve this problem permanently. I am looking at changing how the library is loaded to the same method that JNA uses, and this should remain compatible across JDK updates.

melissalinkert added a commit to melissalinkert/bioformats2raw that referenced this issue Sep 29, 2020
This at least allows simple downsampling to be used in cases where OpenCV
cannot be loaded. See also openpnp/opencv#44
melissalinkert added a commit to melissalinkert/bioformats2raw that referenced this issue Sep 29, 2020
...as suggested in openpnp/opencv#44.
This commit could be reverted if it doesn't solve issues with Java 12+.
@vonnieda vonnieda closed this in c260ed6 Dec 30, 2020
martinschneider added a commit to martinschneider/justtestlah that referenced this issue Dec 31, 2020
See: openpnp/opencv#44 (comment)
Fixed in: openpnp/opencv@c260ed6
@martinschneider
Copy link
Author

@martinschneider martinschneider commented Dec 31, 2020

Thanks a lot for fixing this!

martinschneider added a commit to martinschneider/justtestlah that referenced this issue Jan 1, 2021
@vonnieda
Copy link
Member

@vonnieda vonnieda commented Feb 17, 2021

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

Successfully merging a pull request may close this issue.

None yet
5 participants