java.lang.UnsupportedClassVersionError

I am trying to setup CI for https://github.com/amCap1712/pljava using Travis. But it fails with following log:

find pljava-packaging -name \*.jar | sudo xargs java -jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/gjt/cuspy/JarX has 
been compiled by a more recent version of the Java Runtime (class file version 53.0), this 
version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

The complete build log and travis config is available at https://travis-ci.org/github/amCap1712/pljava/builds/661687014 . I am using OpenJDK9 for this build but it fails for OpenJDK14 as well. How to fix the error ?

Hey @amCap1712,

Try adding this into your .travis.yml:

travis_wait 20

Let me know the results and I’ll help you further.

@Montana I added it as follows:
install: travis_wait 20 "mvn clean install"
Here is the error log:

    travis_wait 20 "mvn clean install"
    Still running (1 of 20): mvn clean install
    The command mvn clean install exited with 127.
    Log:
    mvn clean install: command not found
    /home/travis/.travis/functions: line 607: 8889 Terminated travis_jigger "${!}" "${timeout}" "${cmd[@]}"
    The command "travis_wait 20 "mvn clean install"" failed and exited with 127 during .

First, the error message indicates that the org/gjt/cuspy/JarX package, however you got it, is not compatible with the Java compiler you are using. You are using sudo to invoke java through xargs; root's $PATH (and probably $JAVA_HOME, too) is not set up properly to use Java 9 or 14, or whatever. Unless you need the root privilege to accomplish the desired task, I suggest first dropping sudo.

Second, your build is stalling because you run psql without any argument. This would wait for your interactive input to execute PostgreSQL commands, which never comes in the CI setting. You need to execute commands with -c or another means; e.g., psql -c "select version();".

Third, when using travis_wait, the command should not be quoted (instead, travis_wait 20 mvn clean install). But I don’t think you’ll need that here.

@BanzaiMan I tried without sudo and get permission error. Please see https://travis-ci.org/github/amCap1712/pljava/builds/662045093 . Can instruct me how to fix $PATH or $JAVA_HOME variables?

Your process appears to be trying to write to system directories. I don’t think this is a good idea, and letting root do the job may not render your CI process to succeed, either. I suggest running debug builds to get a better understanding of your own requirements.

@BanzaiMan I need to install a jar file to postgresql directory. Even during normal installation on a PC, root privileges are needed to do this task. The other option would be to install PostgreSQL in user’s directory instead of system. Is that possible or a viable option ?

I am afraid I am unable to advise you on that, since I lack the expertise required. I suggest running the debug build (the feature is already turned on for this repo) to understand the requirements and the possible solutions.

1 Like

Thanks @BanzaiMan, I will do that. Can you assist me further @Montana?