You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Reynolds, Scott" <sc...@agi.com> on 2018/05/01 18:51:58 UTC

Problem finding native shared library (.so)

Hi,

I'm trying to deploy a webapp to Tomcat 8.0.39 on CentOS 7 x86_64 that depends on native shared libraries.  I can't install the shared libraries in a system-wide location because there are multiple applications/webapps being deployed to this system that use different versions of the same native shared libraries.  We're already running two instances of Tomcat to isolate the webapps from one another.  Here's what's going on:

Tomcat #1 (/opt/tomcatwx) - The webapp described below is able to find all necessary native shared libraries

bin/setenv.sh source's bin/setenv-wx.sh.

bin/setenv-wx.sh appends -Djava.library.path=/usr/lib64:/lib64:/lib:/usr/lib:/opt/tomcatwx/lib/gdal to JAVA_OPTS.

conf/catalina.properties appends ,"${catalina.home}/lib/gdal","${catalina.home}/lib/gdal/*.jar" to common.loader.

lib/gdal contains the following files:
drwxr-xr-x. 2 tomcatwx root     4096 Apr 16 01:06 data
-rw-r--r--. 1 tomcatwx root   134785 Apr 16 00:59 gdal.jar
-rwxr-xr-x. 1 tomcatwx root    86176 Apr 16 00:59 libgdalconstjni.so
-rwxr-xr-x. 1 tomcatwx root  1911144 Apr 16 00:59 libgdaljni.so
-rwxr-xr-x. 1 tomcatwx root 93499064 Apr 16 00:59 libgdal.so
-rwxr-xr-x. 1 tomcatwx root   222448 Apr 16 00:59 libgnmjni.so
-rwxr-xr-x. 1 tomcatwx root   968920 Apr 16 00:59 libogrjni.so
-rwxr-xr-x. 1 tomcatwx root   483536 Apr 16 00:59 libosrjni.so
-rw-r--r--. 1 tomcatwx root   335488 Apr 16 15:28 libproj.so
-rw-r--r--. 1 tomcatwx root     2021 Apr 16 01:06 ./lib/gdal/data/gdalicon.png
-rw-r--r--. 1 tomcatwx root    19884 Apr 16 01:06 ./lib/gdal/data/gdalvrt.xsd
-rw-r--r--. 1 tomcatwx root   234839 Apr 16 01:06 ./lib/gdal/data/gdal_datum.csv
-rwxr-xr-x. 1 tomcatwx root  1911144 Apr 16 00:59 ./lib/gdal/libgdaljni.so
-rwxr-xr-x. 1 tomcatwx root    86176 Apr 16 00:59 ./lib/gdal/libgdalconstjni.so
-rw-r--r--. 1 tomcatwx root   134785 Apr 16 00:59 ./lib/gdal/gdal.jar
-rwxr-xr-x. 1 tomcatwx root 93499064 Apr 16 00:59 ./lib/gdal/libgdal.so


Tomcat #2 (/srv/tomcat) - The webapp described below is unable to find a native shared library referenced by the JNI shared library.
Native library load failed.
java.lang.UnsatisfiedLinkError: /srv/tomcat/lib/3p/libgdaljni.so: libgdal.so.20: cannot open shared object file: No such file or directory

bin/setenv.sh source's bin/setenv-3p.sh.

bin/setenv-3-.sh appends -Djava.library.path=/srv/tomcat/lib/3p to JAVA_OPTS.

conf/catalina.properties appends ,"${catalina.home}/lib/3p","${catalina.home}/lib/3p/*.jar" to common.loader.

lib/3p contains the following files:
drwxr-xr-x. 2 tomcat tomcat     4096 Dec  5 20:04 gdal
-rwxr-xr-x. 1 tomcat tomcat   128680 Dec  5 20:06 libgdalconstjni.so
-rwxr-xr-x. 1 tomcat tomcat  1982984 Dec  5 20:06 libgdaljni.so
lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 20:04 libgdal.so -> libgdal.so.20.3.101632
lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 20:04 libgdal.so.20 -> libgdal.so.20.3.101632
-rwxr-xr-x. 1 tomcat tomcat 93494552 Dec  5 20:04 libgdal.so.20.3.101632
-rwxr-xr-x. 1 tomcat tomcat   294464 Dec  5 20:06 libgnmjni.so
-rw-r--r--. 1 tomcat tomcat  3409872 Jul 15  2016 libjhdf5.so
-rw-r--r--. 1 tomcat tomcat  1268496 Jul 15  2016 libjhdf.so
-rwxr-xr-x. 1 tomcat tomcat  1039816 Dec  5 20:06 libogrjni.so
-rwxr-xr-x. 1 tomcat tomcat   554768 Dec  5 20:06 libosrjni.so
lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 19:35 libproj.so -> libproj.so.12.0.03
lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 19:35 libproj.so.12 -> libproj.so.12.0.03
-rwxr-xr-x. 1 tomcat tomcat  1871352 Dec  5 19:35 libproj.so.12.0.03
drwxr-xr-x. 2 tomcat tomcat     4096 Dec  5 19:35 proj

webapps/myapp/WEB-INF/lib contains the JNI jar:
-rw-r--r--. 1 tomcat tomcat 134646 May  1 14:03 webapps/myapp/WEB-INF/lib/gdal-2.2.2.jar

which references libgdaljni.so
libgdaljni.so references libgdal.so
which references libgdal.so.20
which references libgdal.so.20.3.101632

What have I failed to do that is preventing Tomcat/Java from finding the fully resolved libgdal.so that is in the same directory where it found libgdaljni.so?

I tried eliminating the symbolic links by copying  libgdal.so.20.3.101632 to libgdal.so, without success.
I tried copying the gdal-2.2.2.jar to the lib/3p directory, without success.

Thanks in advance for any help.

Scott



Re: Problem finding native shared library (.so)

Posted by Guang Chao <gu...@gmail.com>.
On Wed, May 2, 2018 at 2:51 AM, Reynolds, Scott <sc...@agi.com> wrote:

> Hi,
>
> I'm trying to deploy a webapp to Tomcat 8.0.39 on CentOS 7 x86_64 that
> depends on native shared libraries.  I can't install the shared libraries
> in a system-wide location because there are multiple applications/webapps
> being deployed to this system that use different versions of the same
> native shared libraries.  We're already running two instances of Tomcat to
> isolate the webapps from one another.  Here's what's going on:
>
> Tomcat #1 (/opt/tomcatwx) - The webapp described below is able to find all
> necessary native shared libraries
>
> bin/setenv.sh source's bin/setenv-wx.sh.
>
> bin/setenv-wx.sh appends -Djava.library.path=/usr/
> lib64:/lib64:/lib:/usr/lib:/opt/tomcatwx/lib/gdal to JAVA_OPTS.
>
> conf/catalina.properties appends ,"${catalina.home}/lib/gdal","
> ${catalina.home}/lib/gdal/*.jar" to common.loader.
>
> lib/gdal contains the following files:
> drwxr-xr-x. 2 tomcatwx root     4096 Apr 16 01:06 data
> -rw-r--r--. 1 tomcatwx root   134785 Apr 16 00:59 gdal.jar
> -rwxr-xr-x. 1 tomcatwx root    86176 Apr 16 00:59 libgdalconstjni.so
> -rwxr-xr-x. 1 tomcatwx root  1911144 Apr 16 00:59 libgdaljni.so
> -rwxr-xr-x. 1 tomcatwx root 93499064 Apr 16 00:59 libgdal.so
> -rwxr-xr-x. 1 tomcatwx root   222448 Apr 16 00:59 libgnmjni.so
> -rwxr-xr-x. 1 tomcatwx root   968920 Apr 16 00:59 libogrjni.so
> -rwxr-xr-x. 1 tomcatwx root   483536 Apr 16 00:59 libosrjni.so
> -rw-r--r--. 1 tomcatwx root   335488 Apr 16 15:28 libproj.so
> -rw-r--r--. 1 tomcatwx root     2021 Apr 16 01:06
> ./lib/gdal/data/gdalicon.png
> -rw-r--r--. 1 tomcatwx root    19884 Apr 16 01:06
> ./lib/gdal/data/gdalvrt.xsd
> -rw-r--r--. 1 tomcatwx root   234839 Apr 16 01:06
> ./lib/gdal/data/gdal_datum.csv
> -rwxr-xr-x. 1 tomcatwx root  1911144 Apr 16 00:59 ./lib/gdal/libgdaljni.so
> -rwxr-xr-x. 1 tomcatwx root    86176 Apr 16 00:59
> ./lib/gdal/libgdalconstjni.so
> -rw-r--r--. 1 tomcatwx root   134785 Apr 16 00:59 ./lib/gdal/gdal.jar
> -rwxr-xr-x. 1 tomcatwx root 93499064 Apr 16 00:59 ./lib/gdal/libgdal.so
>
>
> Tomcat #2 (/srv/tomcat) - The webapp described below is unable to find a
> native shared library referenced by the JNI shared library.
> Native library load failed.
> java.lang.UnsatisfiedLinkError: /srv/tomcat/lib/3p/libgdaljni.so:
> libgdal.so.20: cannot open shared object file: No such file or directory
>
> bin/setenv.sh source's bin/setenv-3p.sh.
>
> bin/setenv-3-.sh appends -Djava.library.path=/srv/tomcat/lib/3p to
> JAVA_OPTS.
>
> conf/catalina.properties appends ,"${catalina.home}/lib/3p","${catalina.home}/lib/3p/*.jar"
> to common.loader.
>
> lib/3p contains the following files:
> drwxr-xr-x. 2 tomcat tomcat     4096 Dec  5 20:04 gdal
> -rwxr-xr-x. 1 tomcat tomcat   128680 Dec  5 20:06 libgdalconstjni.so
> -rwxr-xr-x. 1 tomcat tomcat  1982984 Dec  5 20:06 libgdaljni.so
> lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 20:04 libgdal.so ->
> libgdal.so.20.3.101632
> lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 20:04 libgdal.so.20 ->
> libgdal.so.20.3.101632
> -rwxr-xr-x. 1 tomcat tomcat 93494552 Dec  5 20:04 libgdal.so.20.3.101632
> -rwxr-xr-x. 1 tomcat tomcat   294464 Dec  5 20:06 libgnmjni.so
> -rw-r--r--. 1 tomcat tomcat  3409872 Jul 15  2016 libjhdf5.so
> -rw-r--r--. 1 tomcat tomcat  1268496 Jul 15  2016 libjhdf.so
> -rwxr-xr-x. 1 tomcat tomcat  1039816 Dec  5 20:06 libogrjni.so
> -rwxr-xr-x. 1 tomcat tomcat   554768 Dec  5 20:06 libosrjni.so
> lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 19:35 libproj.so ->
> libproj.so.12.0.03
> lrwxrwxrwx. 1 tomcat tomcat       17 Dec  5 19:35 libproj.so.12 ->
> libproj.so.12.0.03
> -rwxr-xr-x. 1 tomcat tomcat  1871352 Dec  5 19:35 libproj.so.12.0.03
> drwxr-xr-x. 2 tomcat tomcat     4096 Dec  5 19:35 proj
>
>
I thought this is just file permission issue, but you have rx for
everyone.  I think your best bet is to remove the synbolink link and copy
libgdal.so.20.3.101632  to libgdal.so.  Why are you using symbolink link on
the second instance but not on the first? Why not just copy the whole file
structure from the first one?


> webapps/myapp/WEB-INF/lib contains the JNI jar:
> -rw-r--r--. 1 tomcat tomcat 134646 May  1 14:03 webapps/myapp/WEB-INF/lib/
> gdal-2.2.2.jar
>
> which references libgdaljni.so
> libgdaljni.so references libgdal.so
> which references libgdal.so.20
> which references libgdal.so.20.3.101632
>
> What have I failed to do that is preventing Tomcat/Java from finding the
> fully resolved libgdal.so that is in the same directory where it found
> libgdaljni.so?
>
> I tried eliminating the symbolic links by copying  libgdal.so.20.3.101632
> to libgdal.so, without success.
> I tried copying the gdal-2.2.2.jar to the lib/3p directory, without
> success.
>
> Thanks in advance for any help.
>
> Scott
>
>
>


-- 
Guang <http://javadevnotes.com/java-copy-array>