Subject: [Pljava-dev] Help in Installing PLjava

From: chap at anastigmatix.net (Chapman Flack)
Date: Sun, 19 Jul 2015 21:05:33 -0400

Anil K Krishna wrote:
> I have installed PostgresSQL on Linux and also followed the steps as
> mentioned in the link below to install PLJava.
> http://www.javacodegeeks.com/2012/10/introduction-to-postgresql-pljava.html
>
> I have created a sample Java function as mentioned below
>
> CREATE FUNCTION getsysprop(VARCHAR)   RETURNS VARCHAR   AS
> 'java.lang.System.getProperty'   LANGUAGE java;
>
> and when I execute this function [SELECT getsysprop('user.home');]
> I am getting the error "Do you want to attempt to reconnect to the
> database" with option yes or no.

Ouch! That indicates that in trying to run your function, the backend
crashed. That's outside of the set of Things That Ought to Happen, and
generally won't, in a Java Virtual Machine, so normally an event like
that would point into the relatively small portion of PL/Java that runs
as native code.

But ... I skimmed the article you were following, and I see that it
suggested a distribution of PL/Java built with gcj instead of a normal
Java runtime, and gcj makes _everything_ into native code. Also, while
I haven't used it myself, I have seen unflattering notes about its
stability. Also, I noticed that article claimed that PL/Java can be
used as a 'trusted' language, and indeed the docs on the PL/Java site
say it can be, *but only when not built with gcj*.

Your test in my environment (with a vanilla Oracle JRE) does what you'd
expect:

SELECT getsysprop('user.home');
     getsysprop
---------------------
 /var/lib/postgresql

So (if you haven't already solved your problem or gone another way),
I would suggest as a very first test, try a vanilla installation with
a conventional JRE, and see if that works better.

Regards,
-Chap