mvn fails to start properly on default installation

Bug #2039222 reported by Joshua Haase
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
maven (Ubuntu)
Confirmed
High
Unassigned

Bug Description

Description: Ubuntu 22.04.3 LTS
Release: 22.04

I just installed maven from the default repository to build a java project.
Running mvn command I get the following error:

```
$ mvn
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
```

I executed the maven launch script with the appropriate `JAVA_HOME` and `MAVEN_HOME`:

```
$ env JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 MAVEN_HOME=/usr/share/maven bash -x mvn
• exec /usr/lib/jvm/java-17-openjdk-amd64/bin/java -classpath '/current-working-directory/boot/plexus-classworlds-.jar' -Dclassworlds.conf=/current-working-directory/bin/m2.conf -Dmaven.home=/current-working-dire ctory -Dlibrary.jansi.path=/current-working-directory/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/current-working-directory/ org.codehaus.plexus.classworlds.launcher.Launcher
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
```

The program should identify the correct MAVEN_HOME instead of trying to use my current working directory.
I can run maven manually using this command, but I would not expect having to diagnose this issue with a package from the official repositories.

```
$ /usr/lib/jvm/java-17-openjdk-amd64/bin/java \
  -classpath /usr/share/maven-repo/:/usr/share/java/:/usr/share/java/plexus-classworlds.jar \
  -Dmaven.home=/usr/share/maven \
  -Dclassworlds.conf=/usr/share/maven/bin/m2.conf \
  -Dlibrary.jansi.path=/usr/share/maven/lib/jansi.jar \
  -Dmaven.multiModuleProjectDirectory=$(pwd) \
  org.codehaus.plexus.classworlds.launcher.Launcher
```

---
External link: https://warthogs.atlassian.net/browse/PEL-634

Tags: maven
Revision history for this message
Joshua Haase (xihh) wrote :

It seems like the program assumes it will be called using the absolute path to the command, the folowing command runs:

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 /usr/share/maven/bin/mvn

Vladimir Petko (vpa1977)
Changed in maven (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Vladimir Petko (vpa1977) wrote :

This is an upstream issue present in the current master branch of maven. The code in mvn does not resolve the path to the mvn shell script[1].

[1] https://github.com/apache/maven/blob/master/apache-maven/src/assembly/shared/mvnvalidate

Luca Corna (lucacorna)
description: updated
Revision history for this message
Maarten Mulders (mthmulders) wrote :

I see that Ubuntu ships version 3.8.7 of Maven. Even if the issue is upstream, I don't think it's very likely to get fixed. The Maven team has released quite a few 3.9.x releases already and is working towards 4.x [1]. My guess is that if the issue is indeed in the Maven code base, it will not receive a lot of attention.

[1] https://maven.apache.org/docs/history.html

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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