RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2096431 - maven:3.6 does not respect JAVA_HOME set by user
Summary: maven:3.6 does not respect JAVA_HOME set by user
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: maven
Version: 9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Marián Konček
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-13 19:28 UTC by jiri vanek
Modified: 2023-05-09 09:23 UTC (History)
7 users (show)

Fixed In Version: maven-3.6.3-15.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:53:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-125156 0 None None None 2022-06-13 19:34:20 UTC
Red Hat Product Errata RHBA-2023:2402 0 None None None 2023-05-09 07:53:27 UTC

Description jiri vanek 2022-06-13 19:28:08 UTC
Description of problem:

JAVA_HOME is not honoured, hard-coded jdk is used instead, thus killing 100% multi-jdk development and purpose of several possible javas in system.

Version-Release number of selected component (if applicable):

maven-3.6.3-14.el9.noarch

Steps to Reproduce:
1. dnf install maven
- that pulls jdk11 in 
2. remove all jdks 
3. extract custom jdk
4 export correctly JAVA_HOME to point to correct custom JDK
5 try to run maven

Actual results:
/usr/bin/mvn --version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

or:

Steps to Reproduce:
1. dnf install maven
- that pulls jdk11 in 
3. extract custom jdk
4 export correctly JAVA_HOME to point to correct custom JDK
5 try to run maven

Actual results:
/usr/bin/mvn --version

Will now work, but will use bad JDK - hardcoded instead of appointed one

Expected results:
Maven will use specified JDK without questioning uses actions, as promised in https://fedoraproject.org/wiki/Changes/Decouple_system_java_setting_from_java_command_setting

Additional info:
This popups form time to time in fedora, but usually gets quickly fixed. I'm wondering why and how it bubbled to rhel

Comment 1 Marián Konček 2022-06-16 13:39:45 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"

Comment 2 Jonathan Dowland 2022-06-28 14:21:10 UTC
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.

Comment 3 jiri vanek 2022-07-25 10:57:24 UTC
(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.

Comment 4 jiri vanek 2022-07-25 13:11:35 UTC
 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

Comment 5 jiri vanek 2022-07-25 13:21:41 UTC
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

Comment 6 Marián Konček 2022-07-26 09:21:26 UTC
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"

Comment 7 Mikolaj Izdebski 2022-08-18 06:35:35 UTC
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

Comment 8 Mikolaj Izdebski 2022-08-18 06:48:07 UTC
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.

Comment 18 Mikolaj Izdebski 2023-02-02 07:53:39 UTC
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

Comment 19 Mikolaj Izdebski 2023-02-02 15:43:33 UTC
Pre-verified.
Gating tests passed or were waived.
Waivers are justified.

Comment 24 errata-xmlrpc 2023-05-09 07:53:24 UTC
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


Note You need to log in before you can comment on or make changes to this bug.