Search This Blog

Sunday, February 3, 2013

Fixing libjvm.so not found issue during PostGIS installation


As mentioned in my previous post, while recently installing PostGIS 2.x on my machine, I ran into some issues. The issue was only discovered when I tried to enable PostGIS extension on a recent database I had created. The compile, build and installation of PostGIS went smoothly with no errors reported.

However, on entering the following command

psql > create extension postgis;


I got the following error

ERROR: could not load library....libjvm.so: cannot open shared object file: No such file or directory

Well, initially that had me baffled. On searching the error, I read that if PostGIS is compiled with the raster option, it relies on the gdal library, which may be looking for the libjvm.so, which it may not be able to find. Executing the program gdalinfo confirmed this suspicion.

$ gdalinfo

gdalinfo: error while loading shared libraries: libjvm.so ....



So, I started looking for jvm on my machine. I found multiple instances of libjvm on my machine, including the one that I was interested in.

$ locate libjvm.so

found multiple libjvm.so library instances.


I decided to make the libjvm.so as part of jdk 1.7 on my machine as the one I wanted the postgis instances to look for.

For this, I went to the folder where libjvm.so was, and entered the following command.

$ sudo ldconfig


Now, to confirm if my issue was resolved, I entered the following command.

$ gdalinfo



Great, it ran the command and told me the parameter list to execute the command. This was clearly an improvement. Next, I logged into psql and tried to re-execute the original command to spatially enable the database.

psql> create extension postgis;



Success!! My issue was resolved.

No comments: