Skip to content

java.sql.SQLNonTransientException: Resolving class org.postgresql.pljava.example.saxon.S9: java.lang.NoClassDefFoundError: net/sf/saxon/trans/XPathException #336

Closed

Description

@df7cb

Hi,
how to I load the example file in 1.6.1?

+ psql -c 'CREATE EXTENSION pljava'
CREATE EXTENSION
Zeit: 1044,297 ms (00:01,044)
+ psql -c 'SELECT sqlj.install_jar('\''file:/srv/projects/postgresql/pljava/postgresql-pljava/debian/postgresql-13-pljava/usr/share/postgresql/13/pljava/pljava-examples-1.6.1.jar'\'', '\''examples'\'', true)'
INFO:  00000: 27 Nov. 20 16:22:14 org.postgresql.pljava.example.LoggerTest aggregate examples ok
ORT:  Java_org_postgresql_pljava_internal_Backend__1log, Backend.c:1967
INFO:  00000: 27 Nov. 20 16:22:15 org.postgresql.pljava.example.annotation.SPIActions issue 228 tests ok
ORT:  Java_org_postgresql_pljava_internal_Backend__1log, Backend.c:1967
FEHLER:  46103: java.sql.SQLNonTransientException: Resolving class org.postgresql.pljava.example.saxon.S9: java.lang.NoClassDefFoundError: net/sf/saxon/trans/XPathException
KONTEXT:  SQL-Anweisung »CREATE OR REPLACE FUNCTION javatest.like_regex( value pg_catalog.varchar, pattern pg_catalog.varchar, flag pg_catalog.varchar DEFAULT CAST(e'' AS pg_catalog.varchar), w3cNewlines boolean DEFAULT CAST(e'false' AS boolean)) RETURNS boolean LANGUAGE java VOLATILE AS e'boolean=org.postgresql.pljava.example.saxon.S9.like_regex(java.lang.String,java.lang.String,java.lang.String,boolean)'«

Activity

  1. jcflack commented on Nov 27, 2020

    @jcflack
    Contributor

    https://tada.github.io/pljava/releasenotes.html#Validation_at_CREATE_FUNCTION_time_may_force_changes_to_deployment_procedures

    TL;DR install the dependent Saxon jar first; the order didn't matter in 1.5 because dependencies weren't checked at CREATE FUNCTION time.

    For the adventuresome, the self-installer jar now includes some test-harnessy features not unlike PostgreSQL's PostgresNode.pm:

    https://tada.github.io/pljava/develop/node.html

  2. jcflack commented on Nov 27, 2020

    @jcflack
    Contributor

    I'm about to begin the formalities of a 1.6.2 release.

    Please don't publish a 1.6.1 package ever. With the #331 bug, it'll just break people's stuff.

  3. df7cb commented on Nov 27, 2020

    @df7cb
    Author

    Aye.

  4. jcflack commented on Nov 28, 2020

    @jcflack
    Contributor

    You mention that users should read the release announcement when upgrading, but I had problems finding that on https://github.com/tada/pljava/wiki. Perhaps that should be linked more prominently.

    Better now?

  5. df7cb commented on Dec 2, 2020

    @df7cb
    Author

    Sorry, what does "install the dependent Saxon jar first" mean? There is no "saxon.jar" file installed by the package, nor on the system.

    + psql -c 'CREATE EXTENSION pljava'
    CREATE EXTENSION
    Time: 492.639 ms
    + psql -c 'SELECT sqlj.set_classpath('\''public'\'', '\''saxon'\'')'
    ERROR:  46102: java.sql.SQLNonTransientException: No such jar: saxon
    LOCATION:  elogExceptionMessage, JNICalls.c:96
    Time: 447.145 ms
    
  6. df7cb commented on Dec 2, 2020

    @df7cb
    Author

    For more context, I'm trying to get https://salsa.debian.org/postgresql/postgresql-pljava/-/blob/master/debian/tests/test.sh running.

    The file is used both from installed-time tests (DESTDIR unset), and at buildtime (when DESTDIR is pointing to $PWD/debian/postgresql-NN-pljava).

  7. jcflack commented on Dec 2, 2020

    @jcflack
    Contributor

    If the build is done with -Psaxon-examples, then an optional set of examples will be built and included in the jar, which require another jar Saxon-HE, which will in that case have been downloaded by Maven and can be found in the local Maven repository as ~/.m2/repository/net/sf/saxon/Saxon-HE/$saxonver/Saxon-HE-$saxonver.jar.

    Now that dependencies are checked by default at function creation time, installing the examples jar without installing the Saxon jar first will normally fail the dependency check.

    There are two ways around that. One is to find the Saxon-HE jar that was downloaded into the Maven repo and install that, add it to the classpath, and then install the examples jar, so the dependency checks are satisfied.

    The other is to SET check_function_bodies TO off; before installing the examples jar, thus disabling the dependency checking. The examples jar will then install successfully, while any later attempts to use the Saxon-based functions will fail at runtime if the dependency jar isn't present. That's essentially how it worked pre-1.6.

    I think it is worthwhile to build the examples with -Psaxon-examples, rather than distributing a version built without it, but that means the test script will need to use one of those two approaches to complete the test installation.

  8. jcflack commented on Dec 18, 2020

    @jcflack
    Contributor

    Is there more I can help with? I notice there doesn't seem to be a package available for 1.5.7 or for 1.6.2.

    I did notice one thing that may need a change in https://salsa.debian.org/postgresql/postgresql-pljava/-/blob/master/debian/tests/test.sh :

      psql -c "ALTER USER $PGUSER SET pljava.module_path = '$PLJAR'"
    

    The module system introduced in Java 9 associates modules with jars, so starting with 1.6 there is a jar for the API and one for the implementation and both have to be on the module_path, so it should look like

      psql -c "ALTER USER $PGUSER SET pljava.module_path = '$PLJAR:$PLAPIJAR'"
    

    where $PLAPIJAR is found the same way as $PLJAR, but matching the glob pljava-api-*.jar.

    Other than that (and testing the examples jar install either with check_function_bodies set to off or with the Saxon-HE jar installed first), I don't see any obvious problems.

  9. df7cb commented on Feb 3, 2021

    @df7cb
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions