tada / pljava

PL/Java is a free add-on module that brings Java™ Stored Procedures, Triggers, Functions, Aggregates, Operators, Types, etc., to the PostgreSQL™ backend.
http://tada.github.io/pljava/
Other
238 stars 77 forks source link

undefined symbol: EmitWarningsOnPlaceholders in pljava 1.6.4 with PostgewSQL 15.1 on RHEL 9 #418

Closed tayalarun1 closed 1 year ago

tayalarun1 commented 1 year ago

Good Morning & Happy new Year 2023

I am trying to install pljava 1.6.4 on PostgreSQL 15.1 on RHEL 9. I was successfully able to follow steps of maven & java jar.

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for PostgreSQL PL/Java 1.6.4:
[INFO]
[INFO] PostgreSQL PL/Java ................................. SUCCESS [  1.934 s]
[INFO] PL/Java API ........................................ SUCCESS [  4.780 s]
[INFO] PL/Java backend Java code .......................... SUCCESS [  3.954 s]
[INFO] PL/Java PGXS ....................................... SUCCESS [  4.557 s]
[INFO] PL/Java backend native code ........................ SUCCESS [ 12.693 s]
[INFO] PL/Java Ant tasks .................................. SUCCESS [ 16.925 s]
[INFO] PL/Java examples ................................... SUCCESS [  6.690 s]
[INFO] PL/Java packaging .................................. SUCCESS [  4.533 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

java -Dpgconfig.sharedir=/usr/pgsql-15/pljava/  -jar pljava-packaging/target/pljava-pg13.jar

Here I have to use pljava-pg13.jar as from maven command I got pljava-pg13.jar jar file & not pljava-pg15.jar. Now I logged into psql (as superuser)

postgres=# SET pljava.libjvm_location TO '/usr/java/jdk-19.0.1/lib/server/libjvm.so';
SET pljava.module_path TO '/usr/pgsql-15/pljava';
SET
SET
postgres=# CREATE EXTENSION pljava;
ERROR:  could not load library "/usr/pgsql-15/lib/libpljava-so-1.6.4.so": /usr/pgsql-15/lib/libpljava-so-1.6.4.so: undefined symbol: EmitWarningsOnPlaceholders

I am blocked as I am not a JAVA person. Appreciate if someone help me here.

Thanks Arun

tayalarun1 commented 1 year ago

Adding versions output for clarity:

$ mvn -version Apache Maven 4.0.0-alpha-3 (2ccf57baa5191468f9911fe85fd99672ac3bacb9) Maven home: /usr/maven/apache-maven-4.0.0-alpha-3 Java version: 19.0.1, vendor: Oracle Corporation, runtime: /usr/java/jdk-19.0.1 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.14.0-162.6.1.el9_1.x86_64", arch: "amd64", family: "unix" $

$ java --version openjdk 19.0.1 2022-10-18 OpenJDK Runtime Environment (build 19.0.1+10-21) OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

$ sudo -u postgres psql psql (15.1) Type "help" for help.

postgres=# select version(); version

PostgreSQL 15.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9), 64-bit (1 row)

postgres=# \q

tayalarun1 commented 1 year ago

Hello,

I cleaned up Postgres & reinstalled using "sudo dnf install -y postgresql15-server". Also installed "sudo dnf install postgresql15-devel". On searching I found "Support PostgreSQL v15 #413" & applied. With this help, I was able to complete mvn clean install & the "java - jar" command.

Now after setting the "pljava.libjvm_location" & "pljava.module_path", when I try to load extension, I get the following error:


postgres=# SET pljava.libjvm_location TO '/usr/java/jdk-19.0.1/lib/server/';
postgres=# SET pljava.module_path TO '/usr/pgsql-15/pljava/pljava/pljava/pljava-1.6.4.jar:/usr/pgsql-15/pljava/pljava/pljava/pljava-api-1.6.4.jar';

postgres=# CREATE EXTENSION pljava;
WARNING:  Java virtual machine not yet loaded
DETAIL:  libjvm: cannot open shared object file: No such file or directory
HINT:  SET pljava.libjvm_location TO the correct path to the jvm library (libjvm.so or jvm.dll, etc.)
ERROR:  cannot use PL/Java before successfully completing its setup
HINT:  Check the log for messages closely preceding this one, detailing what step of setup failed and what will be needed, probably setting one of the "pljava." configuration variables, to complete the setup. If there is not enough help in the log, try again with different settings for "log_min_messages" or "log_error_verbosity".
postgres=#

In case I add "libjvm.so" to pljava.libjvm_location & then try to create extension, it kills my sessions.

postgres=# SET pljava.libjvm_location TO '/usr/java/jdk-19.0.1/lib/server/libjvm.so';
SET
postgres=# SET pljava.module_path TO '/usr/pgsql-15/pljava/pljava/pljava/pljava-1.6.4.jar:/usr/pgsql-15/pljava/pljava/pljava/pljava-api-1.6.4.jar';
SET
postgres=# CREATE EXTENSION pljava;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.

I have already set JAVA_HOME, PATH & LD_LIBRARY_PATH environment variable. Can someone help me here.

Thanks Arun

tayalarun1 commented 1 year ago

I am able to get the root cause of the issue.

After I have installed PostgreSQL 15.1, I have installed "postgresql15-devel". This has also installed JAVA & the path + version of this JAVA is different than the JAVA I have installed manually. This was conflicting.

Once I came to know that there are 2 JAVA, I kept JAVA (of version I have installed) at the front of PATH & it resolved the issue.