Hi, I help maintain the Elasticsearch Learning to Rank Plugin. As part of this Pull Request, we are upgrading to Elasticsearch 7.7. Part of this Elasticsearch now requires Java 14, so we updated our config to oraclejdk14. It seemed to work up until tonight when we were receiving the error when the install Java runs
travis_fold:start:install_jdk
e[0Ke[33;1mInstalling oraclejdk14e[0m
travis_setup_java: command not found
travis_fold:end:install_jdk
Subsequent java -version returns:
$ java -Xmx32m -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
Failure to install Java 14 gives the error when building our code that Java is not up to date:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/o19s/elasticsearch-learning-to-rank/build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'ltr'.
> Failed to apply plugin [class 'org.elasticsearch.gradle.info.GlobalBuildInfoPlugin']
> The compiler java.home must be set to a JDK installation directory for Java 14 but is [/usr/local/lib/jvm/openjdk11] corresponding to [11]
The issue seems to be that Travis does not have this script that sets up the Java installation installed on their VMs anymore.
A quick and dirty fix to get our CI working again is:
First, add this at the top of before-install
before_install:
##########
# TEMPORARY hack to get around Travis not installing Java
# Remove this and the ".travis_install_jdk.sh" file once Travis installs java properly again!
# Copied from the output of the "install_jdk" task in our last successful build
- export JAVA_HOME=~/openjdk14
- export PATH="$JAVA_HOME/bin:$PATH"
- ./.travis_install_jdk.sh --target "/home/travis/openjdk14" --workspace "/home/travis/.cache/install-jdk" --feature "14" --license "GPL" --cacerts
##########
Then download this script and put it in the root of your repository as “.travis_install_jdk.sh”
This script provides support for openJdk9 onwards. Can it be modified for openjdk8 as well? Getting below error. Looks like cacerts issue.
download error: Caught javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty (java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty) while downloading https://repo1.maven.org/maven2/com/github/sbt/sbt-findbugs_2.12_1.0/2.0.0/sbt-findbugs-2.0.0.pom
I decided to part ways from Travis CI’s helper scripts and stuff. Last time it didn’t work when setting up Android emulators. This time it failed with Java. IMO, a stable approach for anyone using OpenJDK is to install it and set the env PATH manually. The only catch is that I used the ‘minimal’ or ‘shell’ image as the base and it also had OpenJDK 11 installed by default.