Bug 2096431
Summary: | maven:3.6 does not respect JAVA_HOME set by user | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 9 | Reporter: | jiri vanek <jvanek> |
Component: | maven | Assignee: | Marián Konček <mkoncek> |
Status: | CLOSED ERRATA | QA Contact: | Martin Kyral <mkyral> |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 9.0 | CC: | jdowland, mizdebsk, mkoncek, mkyral, pmikova, sfroberg, zzambers |
Target Milestone: | rc | Keywords: | Triaged |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | maven-3.6.3-15.el9 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2023-05-09 07:53:24 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
jiri vanek
2022-06-13 19:28:08 UTC
Checked on Fedora Rawhide: # dnf install maven java-latest-openjdk-headless # mvn --version Apache Maven 3.8.5 (Red Hat 3.8.5-2) Maven home: /usr/share/maven Java version: 17.0.3, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.3.0.7-2.fc37.x86_64 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.17.4-200.fc35.x86_64", arch: "amd64", family: "unix" # JAVA_HOME=/usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc37.x86_64/ mvn --version Apache Maven 3.8.5 (Red Hat 3.8.5-2) Maven home: /usr/share/maven Java version: 18.0.1, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc37.x86_64 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.17.4-200.fc35.x86_64", arch: "amd64", family: "unix" For the OpenJDK containers, we hit this when building OpenJ9 variants. The issue was the value hard-coded into /etc/java/maven.conf. Our solution was to 0 that file in our build process. (In reply to Marián Konček from comment #1) > Checked on Fedora Rawhide: > # dnf install maven java-latest-openjdk-headless > > # mvn --version > Apache Maven 3.8.5 (Red Hat 3.8.5-2) > Maven home: /usr/share/maven > Java version: 17.0.3, vendor: Red Hat, Inc., runtime: > /usr/lib/jvm/java-17-openjdk-17.0.3.0.7-2.fc37.x86_64 > Default locale: en, platform encoding: UTF-8 > OS name: "linux", version: "5.17.4-200.fc35.x86_64", arch: "amd64", family: > "unix" > > # JAVA_HOME=/usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc37.x86_64/ > mvn --version > Apache Maven 3.8.5 (Red Hat 3.8.5-2) > Maven home: /usr/share/maven > Java version: 18.0.1, vendor: Red Hat, Inc., runtime: > /usr/lib/jvm/java-18-openjdk-18.0.1.0.10-1.rolling.fc37.x86_64 > Default locale: en, platform encoding: UTF-8 > OS name: "linux", version: "5.17.4-200.fc35.x86_64", arch: "amd64", family: > "unix" I reall Fedora had this glitch in past, how it is possibel that el9 got the broken version.. hard to say. curl https://fedoraproject.org/wiki/Changes/Decouple_system_java_setting_from_java_command_setting#Summary | grep JAVA_HOME <p>By default, Java applications installed from RPMs are run with JVM found on PATH. We propose to run them with default system JVM, not considering PATH. Users will still be able to override the default using JAVA_HOME environment variable as before. <li>if the current environment contains JAVA_HOME variable (typically it doesn't), JVM executable is looked up there</li> <li>if the configuration specifies JAVA_HOME (by default it doesn't), JVM is looked up there</li> <p>If JAVA_HOME is not set (neither in the environment, nor btw: cat /etc/java/maven.conf JAVA_HOME=/usr/lib/jvm/java-11-openjdk ???? cat /etc/java/java.conf | grep usr | grep jvm | wc -l 0 ?? I guerss something changed since https://fedoraproject.org/wiki/Changes/Decouple_system_java_setting_from_java_command_setting#Summary Confirmed on a Beaker machine with RHEL 9: # dnf install maven java-17-openjdk-headless # JAVA_HOME=/usr/lib/jvm/jre-17 mvn --version Apache Maven 3.6.3 (Red Hat 3.6.3-14) Maven home: /usr/share/maven Java version: 11.0.16, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.16.0.8-2.el9.x86_64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.14.0-130.kpq0.el9.x86_64", arch: "amd64", family: "unix" Confirmed. Reproducer: # podman run -it registry.access.redhat.com/ubi9 # dnf -y install maven # JAVA_HOME=dummy mvn -v Expected result: exit code 1, message "The JAVA_HOME environment variable is not defined correctly" Actual result: exit code 0, Maven is ran using JDK 11, it displays version. Scope of the change: fix maven scripts not to override JAVA_HOME from environment Gating tests need to be implemented for all JDKs: 8, 11, 17 This should already be fixed in Fedora, bug #2020478 Fedora change: https://src.fedoraproject.org/rpms/maven/pull-request/31 This should also be fixed in Maven 3.8 in RHEL 9.2. Note regarding verification and test coverage: This bug is covered by /Regression/java-home-override test that checks whether Maven allows overriding JAVA_HOME by calling user. https://src.fedoraproject.org/tests/maven/blob/main/f/Regression/java-home-override Pre-verified. Gating tests passed or were waived. Waivers are justified. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (maven bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:2402 |