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

Removing System.loadLibrary() calls #76

Open
wants to merge 91 commits into
base: master
Choose a base branch
from

Conversation

pmauduit
Copy link

Remove calls to System.loadLibrary (GDAL only, I was not sure on how to rework other ones)

This PR follows the one made on GeoTools here:
planetfederal/geotools#15

Calls to System.loadLibrary() should be done by the GDAL/OGR java bindings (gdal.jar, which most of the time is provided by the distro). With some specific classloaders (e.g. tomcat), a second call to loadLibrary using the same lib as argument raises an exception (UnsatisfiedLinkError: "already loaded in another classloader"), so even if we can make use of the native GDAL lib, it is reported as being unavailable.

Of course, comments are welcome

dromagnoli and others added 30 commits May 25, 2011 14:18
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1264 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1271 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1272 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1275 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1284 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1286 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1289 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1295 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1299 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1303 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1304 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1314 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1336 866bbf7d-4862-ccf5-812a-c90ffd63a74d
git-svn-id: https://svn.java.net/svn/imageio-ext~svn/trunk@1338 866bbf7d-4862-ccf5-812a-c90ffd63a74d
moovida and others added 28 commits February 14, 2013 06:55
Test image reduction to 1x1

Minor fixes on the TIFFMetadataTest and TIFFReadTest
Added png encoder and minor modifications on the ImageOutputStream
Fixing typo
This is not the role of this lib to load it, this has to be done by the
gdal/ogr jar bindings. This presumably could cause issues in some
specific classloading environments (tomcat with several webapps using
the same jars)

If you have a look at gdal sources (generated swig bindings):
swig/java/org/src/gdal/gdal/gdalJNI.java:18:      System.loadLibrary("gdaljni");

The lib should already be loaded there ; this might cause these kind of
messages into Tomcat logs (tested with 2 webapps making use of
imageio-ext):

Native library load failed.
java.lang.UnsatisfiedLinkError: Native Library [...]libgdaljni[...] already loaded in another classloader
Ensures that the underlying class (org.gdal.gdal which would load the
native lib actually) can be resolved by the VM.
Class name is org.gdal.gdal.gdal, adding a catch block, to be able to
debug at runtime more efficiently.
See
pmauduit/geotools@311e84f
for explanations about the motivations.

TL;DR: This is not the role of imageio-Ext to call System.loadLibrary,
this has to be done by the GDAL/OGR java bindings (which most of the
time has to be provided by the distro). With some specific classloaders
(e.g. tomcat), a second call to loadLibrary using the same lib as
argument raises an exception (already loaded in another classloader),
so even if we can make use of the native lib, it is reported as being
unavailable.
@fvanderbiest
Copy link

No feedback on this PR since 9 months ...
At least a thumbs up or down, thanks.

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

Successfully merging this pull request may close these issues.

5 participants