Installing Java 14 fails with "travis_setup_java: command not found"

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]
4 Likes

We’re seeing something similar, though we require Java 8.

Same thing happens with other jdks such as:

  • opendjk8
  • oraclejdk10

Our release build is failing Java Compile now as well. This error is new:

Same here with openjdk8

Same issue, openjdk8

Same for us, openjdk8

getting the same :

Installing openjdk11
travis_setup_java: command not found

configs in travis.yaml:

      language: java
      jdk:
        - openjdk11
      script:
        - cd src/jvm/

When reporting problems, please consider including:

  1. What you are trying to achieve
  2. What you have tried (probably a link to the configuration)
  3. What happened instead (often, pointing to a build log URL, in the form of https://travis-ci.com/OWNER/REPO/build/NNNNNNN would be helpful).
  1. Install Openjdk8
language: java
jdk:
  - openjdk8
sudo: required

services:
- docker

cache:
  directories:
  - "$HOME/.gradle/caches/"
  - "$HOME/.gradle/wrapper/"

install:
- sudo pip install --quiet ansible==2.5.5

before_install:
 - chmod +x gradlew

script:
- "./gradlew check"
- "./gradlew codeCoverageReport"

after_success:
- "bash <(curl -s https://codecov.io/bash)"

deploy:
- provider: script
  script: bash travis/deploy/deploy.sh
  skip_cleanup: true
  on:
    all_branches: true
    condition: $TRAVIS_BRANCH =~ ^(staging|master|dev)$
resolvconf
install_jdk

Installing openjdk8

travis_setup_java: command not found
 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)

$ javac -J-Xmx32m -version

javac 11.0.2
1 Like

We see the same issue with openjdk8.

Config:

https://travis-ci.com/github/seomoz/feedstore/jobs/335454785/config

Build Error:

https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L161

Java ends up defaulting to openjdk11:

https://travis-ci.com/github/seomoz/feedstore/jobs/335454780#L198

It started for us this past Friday, and we can repro the issue by retrying a previously passing build:

https://travis-ci.com/github/seomoz/feedstore/jobs/334573722#L161

Thanks @BanzaiMan

Expected to happen: OpenJDK / Oracle Java 14 installed

Config

language: java
install: true
dist: bionic

jdk:
  - oraclejdk14
  - openjdk14


script:
  - ./gradlew clean check

What happened instead

  • Test was run with Java 11 (system Java?)
  • Apparent failure with Travis installing Java:
travis_fold:start:install_jdk
e[0Ke[33;1mInstalling oraclejdk14e[0m
travis_setup_java: command not found
travis_fold:end:install_jdk

Build Can Be Found here:

https://travis-ci.com/github/o19s/elasticsearch-learning-to-rank/builds/166443238

I’m also seeing this issue, installing openjdk8 with jdk: openjdk8

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

My build problems with openjdk8 was resolved adding the env.

jdk:
  - openjdk8
env:
  - PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH

1 Like

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.

Here’s my fix - https://github.com/ashutoshgngwr/noice/commit/6d31fda81b51a6b5552f59a39dce1ec342fde04c

I am sure similar fix can be invented for Oracle version also.

There might have been a bad deployment. Could you restart the affected builds to confirm things are working as expected?

Thanks.

@BanzaiMan The builds have been breaking for a few days now. I did restart them once or twice and it didn’t work at the time.

1 Like

I’m asking if it works now.