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 2129825 - maven:3.6 should work with just JRE
Summary: maven:3.6 should work with just JRE
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: maven-3.6-module
Version: 8.6
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Mikolaj Izdebski
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-26 11:23 UTC by Jan Lieskovsky
Modified: 2023-05-16 10:10 UTC (History)
6 users (show)

Fixed In Version: maven-3.6-8080020230202141236.9d367344
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2165591 2165593 2165595 (view as bug list)
Environment:
Last Closed: 2023-05-16 08:42:08 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-134884 0 None None None 2022-09-26 11:29:45 UTC
Red Hat Issue Tracker SSOSUP-299 0 None None None 2022-09-26 11:46:06 UTC
Red Hat Product Errata RHBA-2023:2899 0 None None None 2023-05-16 08:42:12 UTC

Description Jan Lieskovsky 2022-09-26 11:23:40 UTC
Description of problem:
Due to the current way on how the "Requires:" RPM spec field of the maven-openjdk11 RPM package (actually any of maven-openjdk8, maven-openjdk11, maven-openjdk17 package) is specified, it's not possible to install the maven package solely using only the JRE bits to run the applications -- in other words to have just "java-11-openjdk-11.0.16.1.1-1.el8_6.x86_64" and "java-11-openjdk-headless-11.0.16.1.1-1.el8_6.x86_64" packages installed, without the corresponding -devel subpackage ("java-11-openjdk-devel-11.0.16.1.1-1.el8_6.x86_64") being installed too.

In other words, in order to be able to install the "maven" RPM package on RHEL-8 system, the underlying JDK installation needs to be a JDK variant, not a JRE variant.

Having maven RPM package installed with JRE variant is not possible, because "maven-openjdk11" RPM in its spec explicitly requires "java-11-openjdk-devel" RPM:

* https://brewweb.engineering.redhat.com/brew/rpminfo?rpmID=10480551

Although certain customers due to the internal restrictions / certification requirements might not be able to have full JDK installed on their systems (only JRE is allowed)


See the links associated to this bug report (the SSOSUP Jira and the customer case) for any further details/motivation behind having this change implemented.

for example of such a request.

Trying to fulfill the aforementioned request it's not possible due to current setting (requirement) of the Requires: spec field of the maven-openjdk11 RPM package (request to remove "java-11-openjdk-devel" package, will in sequence remove / succeed if and only if also both of "maven-openjdk11" and "maven" RPM packages are removed too).

So it's not possible / sufficient to have just java-11-openjdk-headless RPM installed in order to be able to install the "maven" RPM.

The current "Requires:" settings seem a bit way too strict to me (you can still have working maven instance installed despite it not being able to compile new Java code). For example, you can use maven to perform Wildfly / EAP Galleon distribution based build (which doesn't involve the javac compilation itself) and the "java" binary is sufficient to perform such a build successfully.

Therefore our suggestion of this bug (for consideration) being if it would be possible to change the "Requires:" field of the "maven-openjdk11" (actually any maven-openjdk* RPM package) to list just "java-11-openjdk-headless" in the Requires: field, and "java-11-openjdk-devel" only in the "Suggests:" RPM spec field.

This would allow both, install the "maven" RPM package on RHEL-8 system with JDK or JRE based on the actual requirements.

Version-Release number of selected component (if applicable):
java-11-openjdk-11.0.16.1.1-1.el8_6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. (Based on an external/3-rd party request to use just JRE variant), try to remove "java-11-openjdk-devel" RPM package from the system.

Actual results:
maven-openjdk11 and maven RPM packages are required to be removed simultaneously (in the same transaction) the step to be successful.

Expected results:
It's possible to remove the "java-11-openjdk-devel" package without the need to remove "maven-openjdk11" (which is a suggestion for maven) and "maven" packages too.

Additional info:
See aforementioned SSOSUP Jira and customer case for further context behind customers request.

Comment 1 Marián Konček 2022-09-29 10:50:23 UTC
I am not sure how much upstream maven project depends on the existence of development tools such as javac or whether the RPM requirement on java-devel is necessary.
I did some experiments:
$ cd <SOME MAVEN PROJECT>
$ podman run --privileged --mount type=bind,source=.,target=/usr/local/src/project --rm -it fedora:rawhide
# dnf install maven java-17-openjdk-headless
# rpm -e java-17-openjdk-devel --nodeps
# JAVA_HOME=/usr/lib/jvm/jre-17 mvn clean compile

At this point, Maven runs, fetches its dependencies (including "plexus-compiler-javac") and even compiles the sources. The documentation of maven-compiler-plugin [1] at parameter named "<forceJavacCompilerUse>" implies that javac from javax.tools is optional. (`mvn install` command would fail on missing `javadoc` executable.)

I believe upstream Maven *should* be able to work the same way without java-devel installed as I highly doubt it depends on .class files that are not present in JRE but only in JDK. I cannot say this with certainty, but I think we could change the RPM Requires/Suggests fields as requested.

However, Mikolaj will have to confirm whether it works and whether this is actually supported.

[1] https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html

Comment 2 Marián Konček 2022-09-30 09:34:23 UTC
To add onto this: plexus-compiler-javac requires javax.tools at runtime. Since OpenJDK 9, system classes (including javax.tools) are distributed as .class files that are part of modules, not as jars.
In Fedora, installing java-1.8.0-openjdk-headless installs `rt.jar` which is required by java programs to run. This does not include classes in `javax.tools`. Those are provided by tools.jar, which is provided by the package java-1.8.0-openjdk-devel. With OpenJDK 9+ (in context of Fedora: java-11-openjdk-*, java-17-openjdk-*, ...) there are no longer rt.jar / tools.jar, but instead all the .class files are installed by the -headless package. This is the reason why Maven was able to compile sources if used with java-17-openjdk-headless. With java-1.8.0-openjdk-headless (but without -devel) it shouldn't be able to.

I confirmed this:
# dnf install maven-openjdk8
# rpm -e --nodeps java-1.8.0-devel
# JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn -v
...
Java version: 1.8.0_345, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-2.fc38.x86_64/jre
...
# JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn clean compile
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< org.codehaus.plexus:plexus-cipher >------------------
[INFO] Building Plexus Cipher: encryption/decryption Component 2.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ plexus-cipher ---
[INFO] Deleting /usr/local/src/project/target
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-maven) @ plexus-cipher ---
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ plexus-cipher ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /usr/local/src/project/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ plexus-cipher ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /usr/local/src/project/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.671 s
[INFO] Finished at: 2022-09-30T09:13:14Z
[INFO] ------------------------------------------------------------------------

In this case, Maven is still able to execute steps which do not invoke the compiler and fails at the `compile` step.

My conclusion: Maven works without the java-*-openjdk-devel package, even though compiling sources is the primary use case. Replacing Requires for Suggests (+ possible additional changes) seems like a valid move. But I am not confirming this.

Comment 3 Jan Lieskovsky 2022-09-30 10:25:52 UTC
@Marián Konček

Thank you for your research!

(In reply to Marián Konček from comment #2)
> To add onto this: plexus-compiler-javac requires javax.tools at runtime.
> Since OpenJDK 9, system classes (including javax.tools) are distributed as
> .class files that are part of modules, not as jars.
> In Fedora, installing java-1.8.0-openjdk-headless installs `rt.jar` which is
> required by java programs to run. This does not include classes in
> `javax.tools`. Those are provided by tools.jar, which is provided by the
> package java-1.8.0-openjdk-devel. With OpenJDK 9+ (in context of Fedora:
> java-11-openjdk-*, java-17-openjdk-*, ...) there are no longer rt.jar /
> tools.jar, but instead all the .class files are installed by the -headless
> package. This is the reason why Maven was able to compile sources if used
> with java-17-openjdk-headless. With java-1.8.0-openjdk-headless (but without
> -devel) it shouldn't be able to.
> 
> I confirmed this:
> # dnf install maven-openjdk8
> # rpm -e --nodeps java-1.8.0-devel
> # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn -v
> ...
> Java version: 1.8.0_345, vendor: Red Hat, Inc., runtime:
> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-2.fc38.x86_64/jre
> ...
> # JAVA_HOME=/usr/lib/jvm/jre-1.8.0 mvn clean compile
> [INFO] Scanning for projects...
> [INFO] 
> [INFO] -----------------< org.codehaus.plexus:plexus-cipher
> >------------------
> [INFO] Building Plexus Cipher: encryption/decryption Component 2.0.1-SNAPSHOT
> [INFO] --------------------------------[ jar
> ]---------------------------------
> [INFO] 
> [INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ plexus-cipher ---
> [INFO] Deleting /usr/local/src/project/target
> [INFO] 
> [INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-maven) @
> plexus-cipher ---
> [INFO] 
> [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @
> plexus-cipher ---
> [INFO] Using 'UTF-8' encoding to copy filtered resources.
> [INFO] Using 'UTF-8' encoding to copy filtered properties files.
> [INFO] skip non existing resourceDirectory
> /usr/local/src/project/src/main/resources
> [INFO] 
> [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @
> plexus-cipher ---
> [INFO] Changes detected - recompiling the module!
> [INFO] Compiling 5 source files to /usr/local/src/project/target/classes
> [INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR : 
> [INFO] -------------------------------------------------------------
> [ERROR] No compiler is provided in this environment. Perhaps you are running
> on a JRE rather than a JDK?

Right. This is exactly my point. From the error (IMHO) it's clearly visible, what is the
expected action to solve the problem (IOW install the java-*-devel package).

This corresponds to the behavior seen in other (non-Java) tools too. For example
AFAICT you can have the autoconf / automake RPM packages installed without the gcc-11-* / gcc-c++-* 
compilers installed at that moment, and still can run the "./configure" step on the
source code.

In that case it will show an error like "No compiler found", which by itself is sufficient
suggestion for the user to install the necessary gcc-11-* / gcc-c++-* RPM packages to be
able to perform valid "make build" step.

The way the Requires are set on maven currently they are a way too strict IMHO (since
maven can be used for far more actions than building something. The EAP / Wildfly
"composition" of the Galleon build being more example, but there can be more - various
Maven plugins not necessary compiling something).


> [INFO] 1 error
> [INFO] -------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time:  0.671 s
> [INFO] Finished at: 2022-09-30T09:13:14Z
> [INFO]
> ------------------------------------------------------------------------
> 
> In this case, Maven is still able to execute steps which do not invoke the
> compiler and fails at the `compile` step.
> 
> My conclusion: Maven works without the java-*-openjdk-devel package, even
> though compiling sources is the primary use case. Replacing Requires for
> Suggests (+ possible additional changes) seems like a valid move. But I am
> not confirming this.

Regarding the suggested setting of dependencies (set Requires: to java-11-openjdk-headless,
and only Suggests: java-11-openjdk-devel) TBH this wasn't tested. The point was to
modify the hard requirements in the way, only java-11-openjdk-headless would be installed
with maven RPM. And java-11-openjdk-devel would be only suggested, when the user would
perform a "dnf/microdnf" search (IOW it would be recommended to be installed, but not
a strict requirement).

TBH not sure, if Suggests: or Recommends: is the weak dependency to be used for this purpose
(it would need to be tried/tested first).

HTH

Thanks again for your look / follow-up on this one

JFTR: I have modified/deleted the private links in the original c#0 and made that comment public.
Moreover I can also take this discussion to the fedora-devel mailing list, if you want to discuss the proposal
there first. Let me know, if this is expected/desired.

Regards
Jan

Comment 4 Marián Konček 2022-09-30 12:43:21 UTC
Afaik Suggests installs dependencies by default and Recommends does not.
In Fedora there are also packages which do not need a compiler (they only contain .pom) and are "built" with Maven.

I think taking this discussion to fedora-devel or maybe java-devel.org is a good move.

Comment 6 Mikolaj Izdebski 2023-01-26 11:40:54 UTC
Scope of the change:
Replace Requires on java-devel with combination of Recommends and Requires on java-headless

Right now:
  Requires: java-$x-openjdk-devel
After change:
  Requires: java-$x-openjdk-headless
  Recommends: java-$x-openjdk-devel

We'll need new gating tests to ensure that:
1) default installation of Maven pulls in java-devel and that compiler works by default
2) with weak dependencies disabled, only headless java is installed

Comment 7 Marián Konček 2023-02-03 10:21:39 UTC
Pre-verification:
Change was commited to dist-git.
Tests (/Sanity/openjdk-packages) were added and check for absence of java-*-openjdk-devel packages.
Tests passed.

Comment 13 errata-xmlrpc 2023-05-16 08:42:08 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:3.6 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:2899


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