[gdal-dev] Cannot load Java GDAL native library in web application with error in link library?

Ian Turton ijturton at gmail.com
Tue May 23 06:15:51 PDT 2017


Simply add -Djava.library.path="/usr/lib/java/gdal/" to the Tomcat startup
args in /usr/share/tomcat7/bin/catalina.sh or add /usr/lib/java/gdal/ to
your LD_LIBRARY_PATH (and restart tomcat).

Ian

On 23 May 2017 at 14:05, yuchan <a09550 at gmail.com> wrote:

> Hello,
>
> I'm using GDAL library java as a dependency in Java web application with
> Maven dependency:
>
>     <dependency>
>         <groupId>org.gdal</groupId>
>         <artifactId>gdal</artifactId>
>         <version>1.11.1</version>
>     </dependency>
>
> It contains a jar file and runs the native codes in C++ underneath which I
> had to install from packages in Centos. All these shared libraries are
> installed in
>
> ls -l /usr/lib/java/gdal/
> total 1380
> -rwxr-xr-x 3 root root  23288 Feb 14  2016 libgdalconstjni.so
> -rwxr-xr-x 3 root root  23288 Feb 14  2016 libgdalconstjni.so.1
> -rwxr-xr-x 3 root root  23288 Feb 14  2016 libgdalconstjni.so.1.18.4
> -rwxr-xr-x 3 root root 226696 Feb 14  2016 libgdaljni.so
> -rwxr-xr-x 3 root root 226696 Feb 14  2016 libgdaljni.so.1
> -rwxr-xr-x 3 root root 226696 Feb 14  2016 libgdaljni.so.1.18.4
> -rwxr-xr-x 3 root root 136760 Feb 14  2016 libogrjni.so
> -rwxr-xr-x 3 root root 136760 Feb 14  2016 libogrjni.so.1
> -rwxr-xr-x 3 root root 136760 Feb 14  2016 libogrjni.so.1.18.4
> -rwxr-xr-x 3 root root  73816 Feb 14  2016 libosrjni.so
> -rwxr-xr-x 3 root root  73816 Feb 14  2016 libosrjni.so.1
> -rwxr-xr-x 3 root root  73816 Feb 14  2016 libosrjni.so.1.18.4
> However, the web application cannot link as it has a problem to link
> libraries, although what I can see from class loader of Java is:
>
> System.out.println(System.getProperty("java.library.path"));
> /opt/jdk1.8.0_25/jre/lib/amd64:/opt/jdk1.8.0_25/jre/
> lib/i386::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
> which contains the /usr/lib folder.
>
> The error from the GDAL java when I invoke a GDAL API (it does not have
> error if I don't invoke GDAL's methods so other methods still work, Web
> application can run normally) is:
>
> *Caused by: java.lang.UnsatisfiedLinkError:
> org.gdal.osr.osrJNI.new_SpatialReference__SWIG_1()J
> at org.gdal.osr.osrJNI.new_SpatialReference__SWIG_1(Native Method)
> ~[gdal-1.11.1.jar:na]
> at org.gdal.osr.SpatialReference.<init>(SpatialReference.java:117)
> ~[gdal-1.11.1.jar:na]*
>
> I don't know how to solve this problem, tried to find lots of resources but
> no help as I want to deploy this as a Web application in Tomcat server. I
> could make it work when setting in NetBeans IDE with JVM option
>
> -Djava.library.path="/usr/lib/java/gdal/"
> but I know this is not what web application can run.
>
> Thanks,
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.
> nabble.com/Cannot-load-Java-GDAL-native-library-in-web-
> application-with-error-in-link-library-tp5321448.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev




-- 
Ian Turton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170523/4963cbb8/attachment.html>


More information about the gdal-dev mailing list