[gdal-dev] Cannot load Java GDAL native library in web application with error in link library?
yuchan
a09550 at gmail.com
Tue May 23 06:05:34 PDT 2017
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.
More information about the gdal-dev
mailing list