{"action":"created","issue":{"url":"https://api.github.com/repos/geotools/geotools/issues/443","labels_url":"https://api.github.com/repos/geotools/geotools/issues/443/labels{/name}","comments_url":"https://api.github.com/repos/geotools/geotools/issues/443/comments","events_url":"https://api.github.com/repos/geotools/geotools/issues/443/events","html_url":"https://github.com/geotools/geotools/pull/443","id":32468134,"number":443,"title":"Remove load library calls","user":{"login":"pmauduit","id":594335,"avatar_url":"https://avatars.githubusercontent.com/u/594335?v=3","gravatar_id":"","url":"https://api.github.com/users/pmauduit","html_url":"https://github.com/pmauduit","followers_url":"https://api.github.com/users/pmauduit/followers","following_url":"https://api.github.com/users/pmauduit/following{/other_user}","gists_url":"https://api.github.com/users/pmauduit/gists{/gist_id}","starred_url":"https://api.github.com/users/pmauduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmauduit/subscriptions","organizations_url":"https://api.github.com/users/pmauduit/orgs","repos_url":"https://api.github.com/users/pmauduit/repos","events_url":"https://api.github.com/users/pmauduit/events{/privacy}","received_events_url":"https://api.github.com/users/pmauduit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jdeolive","id":114366,"avatar_url":"https://avatars.githubusercontent.com/u/114366?v=3","gravatar_id":"","url":"https://api.github.com/users/jdeolive","html_url":"https://github.com/jdeolive","followers_url":"https://api.github.com/users/jdeolive/followers","following_url":"https://api.github.com/users/jdeolive/following{/other_user}","gists_url":"https://api.github.com/users/jdeolive/gists{/gist_id}","starred_url":"https://api.github.com/users/jdeolive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdeolive/subscriptions","organizations_url":"https://api.github.com/users/jdeolive/orgs","repos_url":"https://api.github.com/users/jdeolive/repos","events_url":"https://api.github.com/users/jdeolive/events{/privacy}","received_events_url":"https://api.github.com/users/jdeolive/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2014-04-29T17:46:37Z","updated_at":"2015-02-13T09:59:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/geotools/geotools/pulls/443","html_url":"https://github.com/geotools/geotools/pull/443","diff_url":"https://github.com/geotools/geotools/pull/443.diff","patch_url":"https://github.com/geotools/geotools/pull/443.patch"},"body":"The main idea behind this PR is to avoid calls to System.loadLibrary()\r\n\r\n(This one was by mistake originally opened onto the fork from boundlessgeo, I apologize for the noise)\r\n\r\nIn some special but common cases, several different calls to System.loadLibrary using the same lib name as argument can lead to undesired behaviours (Raising an exception \"java.lang.UnsatisfiedLinkError: library already loaded in classloader\").\r\n\r\nA typical case of specific classloading is when using the library in several different webapps nested into the same servlet container (tomcat). Even if the library is actually correctly configured and fully available, GeoTools reports it as unavailable (due to the exception thrown).\r\n\r\nA PoC which tends to prove this issue has been provided here: https://github.com/pmauduit/jai-imageio-sample/tree/master/jai-imageio-gdal-sample-webapp\r\n\r\nIn this PoC webapp, a first approach makes use of the JNI GDAL/OGR bindings directly, another one is then attempted using GeoTools (class JniOGRDataStoreFactory). The first one (once tomcat is correctly configured) shows that the library is fully available, though it is reported as unavailable by GeoTools. Duplicating the webapp (so that we can have several contexts trying to use the same native lib) shows that the second one is also unable to access the features that GDAL provides.\r\n\r\nThe litterature I could read on the topic (classloading in Java seems to be one of the big mistery around the language, though) explains that we should avoid packaging webapps with jar files making use of the System.loadLibrary calls. These have to be shared: the jar file should be made available in the higher-level classloader (for tomcat under debian-like distros with libgdal-java installed, it means having a symlink from ${CATALINA_HOME}/lib/gdal.jar pointing to /usr/share/java/gdal.jar)."},"comment":{"url":"https://api.github.com/repos/geotools/geotools/issues/comments/74230282","html_url":"https://github.com/geotools/geotools/pull/443#issuecomment-74230282","issue_url":"https://api.github.com/repos/geotools/geotools/issues/443","id":74230282,"user":{"login":"fvanderbiest","id":265319,"avatar_url":"https://avatars.githubusercontent.com/u/265319?v=3","gravatar_id":"","url":"https://api.github.com/users/fvanderbiest","html_url":"https://github.com/fvanderbiest","followers_url":"https://api.github.com/users/fvanderbiest/followers","following_url":"https://api.github.com/users/fvanderbiest/following{/other_user}","gists_url":"https://api.github.com/users/fvanderbiest/gists{/gist_id}","starred_url":"https://api.github.com/users/fvanderbiest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fvanderbiest/subscriptions","organizations_url":"https://api.github.com/users/fvanderbiest/orgs","repos_url":"https://api.github.com/users/fvanderbiest/repos","events_url":"https://api.github.com/users/fvanderbiest/events{/privacy}","received_events_url":"https://api.github.com/users/fvanderbiest/received_events","type":"User","site_admin":false},"created_at":"2015-02-13T09:59:10Z","updated_at":"2015-02-13T09:59:10Z","body":"Looking for feedback on this one, at least a thumbs up or down. \r\nThanks."}}