New Server Instance "Could not find java in ES_JAVA_HOME at /usr/lib/jvm/java-17-openjdk/bin/java"

I am unable to stand up a new server instance and running into Java Error:
Environment: Rhel 7.9
Docker: sonarqube:9.8 ; postgres:15
Java: OPenJDK Version 17.0.2, JRE 21.9, OPenJDK 64-Bit Server VM21.9
Docker-Compose:

version: "3"
services:
  sonarqube:
    image: sonarqube:latest
    restart: on-failure
    hostname: sonarqube
    container_name: sonarqube
    depends_on:
      - db
    environment:
      SONAR_CORE_SERVERBASEURL:  https://sonarqube.domain.local
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
      SONAR_LOG_LEVEL_APP: INFO
      SONAR_LOG_LEVEL_WEB: DEBUG
      SONAR_LOG_LEVEL_CE: INFO
      SONAR_LOG_LEVEL_ES: INFO
    volumes:
      - /opt/sonarqube/certs/cacerts:/etc/ssl/certs/java/cacerts
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    ports:
      - "9000:9000"

  db:
    image: postgres:latest
    restart: on-failure
    hostname: postgresql
    container_name: postgresql
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
      POSTGRES_DB: sonar
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data 
    ports:
      - "5432:5432"
volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:
  Docker Logs Error: sonarqube | app[] [o.s.a.ProcessLauncherImpl] Launch Process [ELASTICSEARCH] FROM [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch/
                                                   Sonarqube | could not find java in ES_JAVA_HOME at /usr/lib/jvm/java-17-openjdk/bin/java
                                                     Sonarqube | process exitied with exit value [elasticsearch]: 1
                                                    Sonarqube | Process Elasticsearch is stopped 
                                                    Sonarqube | Sonarqube is stopped 
                                                                                Exited with code 0

Hey @linzwelch,

thanks for posting on our community! I was docker-composing your file (with the exception of the java-certs mounting), but I can’t hit any issues.

Let me ask you a few questions to understand your context better:

  • You use our sonarqube:latest. This means that you are using SonarQube 9.9 community edition: is it your intention, right? I’m asking because you mention to run SQ 9.8. Are you trying to migrate from SonarQube 9.8 to 9.9?
  • The env variable ES_JAVA_HOME does need to be set explicitly by you. Could you please make sure that is unset?

I would like to ask you also to give a try running the image on a fresh volume, just to check if the issue is related to some past configurations.

I have tried a fresh install of 9.8 (on the original post) about a week ago and have been troubleshooting different java errors related to ```
could not find java in ES_JAVA_HOME
“”"
This morning i tried a separate server and fresh install with SQ9.9/PG:13/Java11/same docker-compose based on various forums and suggestions trying different versions to see if i had pulled a bad image and i am still running into java errors.
I assume that i need to install java in a specific manner for Sonarqube but am unsure what all it needs to be successful

Hi @linzwelch,

another question for you: which is the version of your Docker engine?

While getting this info, may I ask you to try docker-composing this file? It’s one of the docker-compose examples that we provide in our repo and that seems to fit your use case well. Please remove all existing SonarQube-related volumes to have a fresh installation of this file.

Please also note that, if you install SonarQube via a docker-compose file, we don’t require you to have any specific Java version (the SQ image contains everything you need to bootstrap the SQ app).

1 Like

What’s your docker version? There was a error like this when running a more recent Alpine on a old docker version that the seccomp filter would denie a required system call of elasticsearch. Maybe you have a outdated docker runtime that you can just upgrade.

There is a workaround defined here: Attempting to start sonarQube container from image yields various exceptions while following official SonarQube Documentation - #3 by Tobias_Trabelsi

3 Likes

I am running Docker 19.03.9/Compose 2.11.0
I was able to get it working with Java 11.0.16 and adding a line to my compose file

security_opt:
    -seccomp:unconfined

Thanks for the update, @linzwelch!

Your docker-engine version is indeed pretty old. Just for future reference, the fix to similar problems one would need either to upgrade the docker engine (preferred way) or use one of the following workarounds:

  • Change the default action in your seccomp profile (line 2) to return SCMP_ACT_TRACE instead of SCMP_ACT_ERRNO. (see @DefinitelyNotTobi’s answer here)
  • Pass unconfined to run the SQ container without the default seccomp profile (as shown by @linzwelch in the comment above).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.