From: Pierre M. <pie...@ca...> - 2014-04-29 18:51:50
|
Hi list, I recently proposed a pull-request on geotools[1] and imageio-ext[2], which aims to limit the number of System.loadLibrary() concerning the GDAL native lib, and maybe I should have asked here before posting them, so excuse me if do things in the wrong order ;-) The main motivation about this proposal is that we encountered issues when several webapps were trying to make use of the same native library in the same tomcat container. While digging in the issue, I noticed in the tomcat logs that even if it was correctly configured to be able to resolve the native lib path, it refused to load GDAL more than once (any further initializations of the GDAL bindings were causing a "UnsatisfiedLinkError: Native library <lib> already loaded in another classloader", then only the first initialized webapp could use JNI GDAL/OGR bindings). Willing to fix the issue, I developed a sample webapp that I duplicated 2 times in the same tomcat environment, ensuring that 1. the bindings were available while calling them directly, and enumerating GDAL and OGR drivers, 2. they were also available using GeoTools related classes (which basically were doing the same thing as previously), and it worked. My point of view on the problem is that the gdal.jar bindings should be shared across the webapps (using CATALINA_HOME/lib for instance) instead of being packaged into each ones, and that the loadlibrary should be done at a higher level of classloading (i.e. ensuring that no jars bundled into the webapps would call System.loadLibrary by themselves), anyway I'd like to get some comments about it, maybe I'm wrong and this is not the way to fix the issue, and maybe it is already done this way for a particular reason I'm not aware of. So what do you think about it ? I'd be glad to have some feedbacks on this. Best regards, and thanks, [1] https://github.com/geotools/geotools/pull/443 [2] https://github.com/geosolutions-it/imageio-ext/pull/76 -- Pierre Mauduit Ingénieur développement Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel (France) : +33 4 79 26 58 02 Fax : 04 79 70 15 81 Mail : pie...@ca... <yve...@ca...> http://www.camptocamp.com |