Re: Problem running examples.jar with official postgresql pljava deb

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Bear Giles <bgiles(at)coyotesong(dot)com>, pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: Problem running examples.jar with official postgresql pljava deb
Date: 2022-03-05 21:47:53
Message-ID: 6223DA89.80607@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 03/05/22 16:10, Bear Giles wrote:
> INFO: 05 Mar 22 21:01:28 org.postgresql.pljava.example.LoggerTest
> aggregate examples ok
> INFO: 05 Mar 22 21:01:28
> org.postgresql.pljava.example.annotation.SPIActions issue 228 tests ok
> ERROR: java.sql.SQLNonTransientException: resolving static method
> org.postgresql.pljava.example.saxon.S9.like_regex with signature
> (String,String,String,boolean)boolean: java.lang.ClassNotFoundException:
> net.sf.saxon.trans.XPathException

I think you are running into the known complication that was introduced
with 1.6.0, where functions are now validated at CREATE FUNCTION time,
and can fail if a dependency isn't resolvable at that time. That's
described here:

http://tada.github.io/pljava/examples/examples.html#Exception_resolving_class_or_method_.28message_when_installing_examples.29

with two different ways you can proceed:

Install the required dependency first. Use sqlj.install_jar to install
the Saxon jar (as described here), and sqlj.set_classpath to make it
accessible, and then use sqlj.install_jar to install the examples jar
itself. The dependency will be satisfied and all of the example functions
will work.

Use SET check_function_bodies TO off before installing the examples jar.
That will simply relax the strict checking at CREATE FUNCTION time, so that
all of the example functions will be created. The ones that require Saxon,
of course, won’t work; SET check_function_bodies TO off simply means you get
the errors later, when trying to use the functions, instead of when creating
them. If you install the dependency jar later and add it to the class path,
those functions will then work.

The Saxon jar is pure library code; it doesn't declare any PL/Java
functions. So no particular schema needs to exist before installing it.
Of course, it needs to be added to a classpath before installing
the examples jar (if using the dependency-first approach). I generally
just add it to the public schema, which is the fallback for other schema
class paths.

SELECT sqlj.set_classpath('public', 'saxon');

Or, you might find it more convenient to use the
SET check_function_bodies TO off; approach, install the examples jar first,
then install the saxon jar, and finish by setting the schema classpath
for javatest (which will exist by that point) to 'examples:saxon'.

Regards,
-Chap

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Bear Giles 2022-03-05 23:16:29 Re: Problem running examples.jar with official postgresql pljava deb
Previous Message Bear Giles 2022-03-05 21:22:13 jOOQ custom data types for pl/java UDT