Pivotal Greenplum Database (GPDB) 4.3.x
When we attempt to enable pl/java for a database, it returns the following error:
psql -d adw -f $GPHOME/share/postgresql/pljava/install.sql
psql:/opt/greenplum/greenplum-db/./share/postgresql/pljava/install.sql:1: ERROR: could not load library "/opt/greenplum/greenplum-db-220.127.116.11/lib/postgresql/pljava.so": libjvm.so: cannot open shared object file: No such file or directory
psql:/opt/greenplum/greenplum-db/./share/postgresql/pljava/install.sql:2: ERROR: could not load library "/opt/greenplum/greenplum-db-18.104.22.168/lib/postgresql/pljava.so": libjvm.so: cannot open shared object file: No such file or directory
Refer to this link and restart the cluster, then the issue will most probably be resolved.
But sometimes this issue might possibly remain even after restarting the Database. It happens because of the incorrect environment variable setting that results in a failure to find the library libjvm.so.
Firstly, check where libjvm.so actually resides:
[root@dw-greenplum-1 Downloads]# find / -name libjvm.so
Then, check the file $GPHOME/greeplum_path.sh:
We can find the variable JAVA_HOME pointing to a directory that does not contain the file libjvm.so. So we can correct the value JAVA_HOME to "$GPHOME/ext/jre-1.6.0_32". Make sure to apply this change to master and all segments.
Now, restart the cluster and source $GPHOME/greenplum_path.sh.
Make sure that the JAVA_HOME value is correct for master and segments. If one of the segments has an incorrect value, the installation will fail with the same error.