[SRU] Maven 3.6.3-1 fails to run with OpenJDK 17

Bug #1930541 reported by Manuel J.
86
This bug affects 17 people
Affects Status Importance Assigned to Milestone
guice (Ubuntu)
Confirmed
Undecided
Unassigned
Focal
New
Undecided
Unassigned
maven (Debian)
Fix Released
Unknown
maven (Ubuntu)
Confirmed
Undecided
Unassigned
Focal
New
Undecided
Unassigned

Bug Description

[Impact]
Maven 3.6.3-1 fails to run with OpenJDK 16 and 17.
Users building for OpenJDK 17 are unable to use the packaged Maven.

This bug was fixed in Maven 3.6.3-2 (and above)[1]
Packages maven and guice need to be updated in focal to fix this bug.

[Test Plan]
For the version in the release pocket and the version in the proposed pocket, use maven to compile https://github.com/socialsoftware/quizzes-tutor:
$ sudo apt install openjdk-17-jdk maven=$VERSION
$ git clone https://github.com/socialsoftware/quizzes-tutor.git
$ cd quizzes-tutor
$ cd backend
$ mvn clean compile

This should fail for the version in the release pocket, with the error below, and succeed for the version in the proposed pocket.

Sample test script:
```
#!/bin/bash
set -ex
lxc launch ubuntu:focal tester
lxc exec tester -- apt install -y software-properties-common
lxc exec tester -- add-apt-repository -y ppa:vpa1977/maven-sru-2
lxc exec tester -- apt install -y maven openjdk-17-jdk-headless
lxc exec tester -- git clone https://github.com/socialsoftware/quizzes-tutor.git
lxc exec tester -- /bin/sh -c "cd quizzes-tutor/backend && mvn clean compile"
lxc delete -f tester

```

[Where problems could occur]

Guice:
 - this SRU installs a new artifact - guice-no-aop-4.2.1.jar. There is no other impact for this package.
Maven:
 - guice.jar is replaced with guice-no-aop.jar. This is optional[2] functionality and Apache's release of maven 3.6.3 includes `guice-4.2.1-no_aop.jar`[3]

- Maven should be tested against Java versions present in focal, e.g. test building a sample project:
```
#!/bin/bash
set -ex

for x in openjdk-11-jdk-headless openjdk-13-jdk-headless openjdk-16-jdk-headless openjdk-17-jdk-headless openjdk-8-jdk-headless; do
    lxc launch ubuntu:focal tester
    lxc exec tester -- apt install -y software-properties-common
    lxc exec tester -- add-apt-repository -y ppa:vpa1977/maven-sru-2
    lxc exec tester -- apt install -y maven $x
    lxc exec tester -- git clone https://github.com/mkyong/maven-examples
    for module in java-multi-modules java-project maven-code-coverage maven-mutation-testing maven-profiles maven-static-code-analysis maven-unit-test; do
        lxc exec tester -- /bin/sh -c "cd maven-examples/$module && mvn clean compile"
    done
    lxc delete -f tester
done
```

[Original Description]
*System info*:
```
$ lsb_release -rd
Description: Ubuntu 20.04.2 LTS
Release: 20.04

$ apt-cache policy maven
maven:
  Installed: 3.6.3-1
  Candidate: 3.6.3-1
  Version table:
 *** 3.6.3-1 500
        500 http://ch.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        500 http://ch.archive.ubuntu.com/ubuntu focal/universe i386 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy openjdk-16-jdk
openjdk-16-jdk:
  Installed: 16.0.1+9-1~20.04
  Candidate: 16.0.1+9-1~20.04
  Version table:
 *** 16.0.1+9-1~20.04 500
        500 http://ch.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        500 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
```

*Summary*
Maven 3.6.3-1 apparently fails to run with OpenJDK 16. It seems to be a bug and was fixed in Maven 3.6.3-2 (and above) according to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467.

*Expected behaviour*
I expect to be able to use maven with all currently supported General Availability Java versions.

*Observed behaviour*
I installed OpenJDK 16 (via PPA, see version above) and tried to compile a Maven project, producing the following output:
```
$ mvn compile
[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper

$ echo $?
1
```

Thanks and kind regards,
-Manu

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467
[2] https://github.com/google/guice/wiki/OptionalAOP
[3] https://github.com/apache/maven/releases/tag/maven-3.6.3

Tags: fr-5268
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in maven (Ubuntu):
status: New → Confirmed
Revision history for this message
John Neffenger (jgneff) wrote :

Now that Ubuntu 20.04 LTS provides the OpenJDK 16 package in the updates pocket (since May 10, 2021), it would be great to have the fix in Ubuntu Maven 3.6.3-2 back-ported to Ubuntu 20.04. I'm working around the problem by installing a local copy of Maven 3.8.1 directly from Apache.

$ apt-cache policy openjdk-16-jdk
openjdk-16-jdk:
  Installed: 16.0.1+9-1~20.04
  Candidate: 16.0.1+9-1~20.04
  Version table:
 *** 16.0.1+9-1~20.04 500
        500 http://ca.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        100 /var/lib/dpkg/status

Without the fix, installing OpenJDK 16 breaks Maven.

Revision history for this message
clerum (cody-lerum) wrote :

This is a blocker for using JDK 16 (release 16 March 2021) along with Maven on 20.04.

This will also be a blocker for the next LTS Java 17 release in September 2021

Revision history for this message
clerum (cody-lerum) wrote :

Is there any assistance I can provide to move this forward?

Revision history for this message
Rural Hunter (ruralhunter) wrote :

Please fix it ASAP!

Revision history for this message
mjw99 (mark-williamson) wrote :

This might be a solution from the Debian folk:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=948310

summary: - Maven 3.6.3-1 fails to run with OpenJDK 16
+ Maven 3.6.3-1 fails to run with OpenJDK 16 and 17
Revision history for this message
Matthew Barry (komputerwiz) wrote : Re: Maven 3.6.3-1 fails to run with OpenJDK 16 and 17

The upstream fix from Debian requires guice >=4.2.3 and, implicitly, a newer version of guava (Debian repo has 29.0). The current available versions in Ubuntu 20.04 are guice 4.2.1 and guava 19.0, so both of these package updates will have to be backported.

Attempting to build maven 3.6.3 with the changes described by the commit in the upstream bug report (https://salsa.debian.org/java-team/maven/-/commit/48fb5b2ae0dcd860d61e4b258d60fcee03d2713c) resulted in maven packages that were missing some required "Depends" declarations, for example libcommons-cli-java and libgeronimo-annotation-1.3-spec-java. These are listed as "Build-Depends" and installing them does allow maven to run on Java 16+.

Hopefully there is some useful info here for the maintainers.

Revision history for this message
Wim (wvdgraaf) wrote :

Can we expect a fix? Java 17 is a LTS release, so a working version of Maven would be very helpful. Or do we have to wait half a year for Ubuntu 22.04 to arrive? Thanks!

Revision history for this message
Gavriel Fleischer (flocsy) wrote :

Any update on this? Do I have to upgrade to Ubuntu 22.04 or is there hope for a fix in Ubuntu 20.04?

Revision history for this message
Tom Misilo (tmisilo) wrote :

Just updating that is is still an issue in 2023, with 20.04.6

Changed in guice (Ubuntu):
status: New → Confirmed
summary: - Maven 3.6.3-1 fails to run with OpenJDK 16 and 17
+ [SRU] Maven 3.6.3-1 fails to run with OpenJDK 17
description: updated
Changed in maven (Debian):
status: Unknown → Fix Released
Revision history for this message
Luís Infante da Câmara (luis220413) wrote :
Revision history for this message
Luís Infante da Câmara (luis220413) wrote (last edit ): Re: Maven 3.6.3-1 fails to run with OpenJDK 17

The debdiffs for Maven and maven-resolver are in bug #1922654.

summary: - [SRU] Maven 3.6.3-1 fails to run with OpenJDK 17
+ Maven 3.6.3-1 fails to run with OpenJDK 17
Vladimir Petko (vpa1977)
tags: added: fr-5268
Vladimir Petko (vpa1977)
description: updated
description: updated
Vladimir Petko (vpa1977)
description: updated
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Guice that produces no AOP artifact.

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Maven that uses no aop guice artifacts

Vladimir Petko (vpa1977)
description: updated
Vladimir Petko (vpa1977)
description: updated
description: updated
Vladimir Petko (vpa1977)
description: updated
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Tested with PPA: ppa:vpa1977/maven-sru-2[1]

[1] https://launchpad.net/~vpa1977/+archive/ubuntu/maven-sru-2/+packages

Revision history for this message
Vladimir Petko (vpa1977) wrote :

piuparts test

Revision history for this message
Vladimir Petko (vpa1977) wrote :

piuparts test: upgrade to jammy

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Build Java 17 project

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Build sample maven projects with available openjdk-* packages

description: updated
Vladimir Petko (vpa1977)
summary: - Maven 3.6.3-1 fails to run with OpenJDK 17
+ [SRU] Maven 3.6.3-1 fails to run with OpenJDK 17
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.