無法在 JDK7 上運行 Maven 3.6.3 (Can't run Maven 3.6.3 on JDK7)


問題描述

無法在 JDK7 上運行 Maven 3.6.3 (Can't run Maven 3.6.3 on JDK7)

└─❯ mvn ‑version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation, runtime: /home/jqno/.jabba/jdk/1.7.80‑oracle/jre
Default locale: en_US, platform encoding: UTF‑8
OS name: "linux", version: "5.11.0‑16‑generic", arch: "amd64", family: "unix"

看起來,Maven 嘗試加載為 JDK8 編譯的類,因為它抱怨 52.0 的類版本不受支持。但是我找不到哪個類,或者為什麼 Maven 首先嘗試加載它。我在 Google 上找到的所有內容似乎都無關。

發生了什麼事?我該如何解決這個問題?

更新我已經解壓了 /usr/share/maven/lib/guice‑no‑aop.jar 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。

Maven 嘗試加載為 JDK8 編譯的類,因為它抱怨 52.0 的類版本不受支持。但是我找不到哪個類,或者為什麼 Maven 首先嘗試加載它。我在 Google 上找到的所有內容似乎都無關。</p>

發生了什麼事?我該如何解決這個問題?

更新我已經解壓了 /usr/share/maven/lib/guice‑no‑aop.jar 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。

Maven 嘗試加載為 JDK8 編譯的類,因為它抱怨 52.0 的類版本不受支持。但是我找不到哪個類,或者為什麼 Maven 首先嘗試加載它。我在 Google 上找到的所有內容似乎都無關。</p>

發生了什麼事?我該如何解決這個問題?

更新我已經解壓了 /usr/share/maven/lib/guice‑no‑aop.jar 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。

或者為什麼 Maven 首先嘗試加載它。我在 Google 上找到的所有內容似乎都無關。</p>

發生了什麼事?我該如何解決這個問題?

更新我已經解壓了 /usr/share/maven/lib/guice‑no‑aop.jar 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。

或者為什麼 Maven 首先嘗試加載它。我在 Google 上找到的所有內容似乎都無關。</p>

發生了什麼事?我該如何解決這個問題?

更新我已經解壓了 /usr/share/maven/lib/guice‑no‑aop.jar 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。

文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。</p> 文件並運行 javap ‑verbose com.google.inject.Module,它確實有 52.0 版本。我不知道該文件是如何到達那裡的(我假設它是由 apt install maven 安裝的,但我不確定)。</p>


參考解法

方法 1:

The problem here is that Ubuntu has repackaged Maven which in result produces the issue.

As shown here if you check the version via:

mvn ‑‑version

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation, runtime: /home/jqno/.jabba/jdk/1.7.80‑oracle/jre
Default locale: en_US, platform encoding: UTF‑8
OS name: "linux", version: "5.11.0‑16‑generic", arch: "amd64", family: "unix"

This shows that you are NOT using Apache Maven.

If you do that on plain command line and install Apache Maven via https://maven.apache.org/download.cgi you will get an output like this:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/XXX/tools/maven
Java version: 1.7.0_302, vendor: Azul Systems, Inc., runtime: /Users/khmarbaise/.sdkman/candidates/java/7.0.302‑zulu/zulu‑7.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF‑8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"

The most important part is the first line:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

This is Apache Maven.

Second if you take careful look into the error output:

constituent[0]: file:/usr/share/maven/conf/logging/
constituent[1]: file:/usr/share/maven/lib/commons‑lang3.jar
constituent[2]: file:/usr/share/maven/lib/sisu‑plexus.jar
constituent[3]: file:/usr/share/maven/lib/maven‑core‑3.x.jar
constituent[4]: file:/usr/share/maven/lib/maven‑shared‑utils.jar
constituent[5]: file:/usr/share/maven/lib/sisu‑inject.jar
constituent[6]: file:/usr/share/maven/lib/jansi.jar
constituent[7]: file:/usr/share/maven/lib/plexus‑component‑annotations.jar
constituent[8]: file:/usr/share/maven/lib/plexus‑interpolation.jar
constituent[9]: file:/usr/share/maven/lib/maven‑settings‑builder‑3.x.jar
constituent[10]: file:/usr/share/maven/lib/aopalliance.jar
constituent[11]: file:/usr/share/maven/lib/wagon‑provider‑api.jar
constituent[12]: file:/usr/share/maven/lib/jsr250‑api.jar
constituent[13]: file:/usr/share/maven/lib/slf4j‑api.jar
constituent[14]: file:/usr/share/maven/lib/plexus‑cipher.jar
constituent[15]: file:/usr/share/maven/lib/maven‑slf4j‑provider‑3.x.jar
constituent[16]: file:/usr/share/maven/lib/maven‑resolver‑transport‑wagon.jar
constituent[17]: file:/usr/share/maven/lib/wagon‑file.jar
constituent[18]: file:/usr/share/maven/lib/plexus‑sec‑dispatcher.jar
constituent[19]: file:/usr/share/maven/lib/maven‑resolver‑provider‑3.x.jar
constituent[20]: file:/usr/share/maven/lib/jcl‑over‑slf4j.jar
constituent[21]: file:/usr/share/maven/lib/wagon‑http‑shaded.jar
constituent[22]: file:/usr/share/maven/lib/maven‑compat‑3.x.jar
constituent[23]: file:/usr/share/maven/lib/guice‑no‑aop.jar
constituent[24]: file:/usr/share/maven/lib/maven‑artifact‑3.x.jar
constituent[25]: file:/usr/share/maven/lib/guava.jar
constituent[26]: file:/usr/share/maven/lib/maven‑resolver‑connector‑basic.jar
constituent[27]: file:/usr/share/maven/lib/commons‑cli.jar
constituent[28]: file:/usr/share/maven/lib/maven‑builder‑support‑3.x.jar
constituent[29]: file:/usr/share/maven/lib/maven‑resolver‑api.jar
constituent[30]: file:/usr/share/maven/lib/plexus‑utils.jar
constituent[31]: file:/usr/share/maven/lib/maven‑settings‑3.x.jar
constituent[32]: file:/usr/share/maven/lib/maven‑resolver‑util.jar
constituent[33]: file:/usr/share/maven/lib/maven‑resolver‑impl.jar
constituent[34]: file:/usr/share/maven/lib/cdi‑api.jar
constituent[35]: file:/usr/share/maven/lib/maven‑resolver‑spi.jar
constituent[36]: file:/usr/share/maven/lib/maven‑embedder‑3.x.jar
constituent[37]: file:/usr/share/maven/lib/maven‑repository‑metadata‑3.x.jar
constituent[38]: file:/usr/share/maven/lib/commons‑io.jar
constituent[39]: file:/usr/share/maven/lib/maven‑model‑builder‑3.x.jar
constituent[40]: file:/usr/share/maven/lib/maven‑plugin‑api‑3.x.jar
constituent[41]: file:/usr/share/maven/lib/maven‑model‑3.x.jar
constituent[42]: file:/usr/share/maven/lib/javax.inject.jar

Than you can see things like this:

constituent[3]: file:/usr/share/maven/lib/maven‑core‑3.x.jar
..
constituent[25]: file:/usr/share/maven/lib/guice‑no‑aop.jar

If you take a look into an original Apache Maven lib directory the files look like this:

javaee (master *)$ ls ‑la ~/tools/apache‑maven‑3.6.3/lib/
total 21000
drwxr‑xr‑x  65 khmarbaise  staff     2080 Nov  7  2019 .
drwxr‑xr‑x   9 khmarbaise  staff      288 Nov 21  2019 ..
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    44908 Nov  7  2019 cdi‑api‑1.0.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 cdi‑api.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    53820 Nov  7  2019 commons‑cli‑1.4.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 commons‑cli.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   208700 Nov  7  2019 commons‑io‑2.5.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 commons‑io.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   501879 Nov  7  2019 commons‑lang3‑3.8.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 commons‑lang3.license
drwxr‑xr‑x   3 khmarbaise  staff       96 Nov  7  2019 ext
‑rw‑r‑‑r‑‑   1 khmarbaise  staff  2591373 Nov  7  2019 guava‑25.1‑android.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 guava.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   520662 Nov  7  2019 guice‑4.2.1‑no_aop.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 guice.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   283858 Nov  7  2019 jansi‑1.17.1.jar
drwxr‑xr‑x  10 khmarbaise  staff      320 Nov  7  2019 jansi‑native
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 jansi.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff     2497 Nov  7  2019 javax.inject‑1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 javax.inject.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    16539 Nov  7  2019 jcl‑over‑slf4j‑1.7.29.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 jcl‑over‑slf4j.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   397115 Nov  7  2019 jsoup‑1.12.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff     1192 Nov  7  2019 jsoup.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff     5848 Nov  7  2019 jsr250‑api‑1.0.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    20545 Nov  7  2019 jsr250‑api.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    57824 Nov  7  2019 maven‑artifact‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    14262 Nov  7  2019 maven‑builder‑support‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   287955 Nov  7  2019 maven‑compat‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   633028 Nov  7  2019 maven‑core‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    98096 Nov  7  2019 maven‑embedder‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   215412 Nov  7  2019 maven‑model‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   192302 Nov  7  2019 maven‑model‑builder‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    47035 Nov  7  2019 maven‑plugin‑api‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    27158 Nov  7  2019 maven‑repository‑metadata‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   148983 Nov  7  2019 maven‑resolver‑api‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    44143 Nov  7  2019 maven‑resolver‑connector‑basic‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   180696 Nov  7  2019 maven‑resolver‑impl‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    66242 Nov  7  2019 maven‑resolver‑provider‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    36732 Nov  7  2019 maven‑resolver‑spi‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    31013 Nov  7  2019 maven‑resolver‑transport‑wagon‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   167529 Nov  7  2019 maven‑resolver‑util‑1.4.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    44047 Nov  7  2019 maven‑settings‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    42090 Nov  7  2019 maven‑settings‑builder‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   166562 Nov  7  2019 maven‑shared‑utils‑3.2.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    23815 Nov  7  2019 maven‑slf4j‑provider‑3.6.3.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   379197 Nov  7  2019 org.eclipse.sisu.inject‑0.3.4.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11530 Nov  7  2019 org.eclipse.sisu.inject.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   205323 Nov  7  2019 org.eclipse.sisu.plexus‑0.3.4.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11530 Nov  7  2019 org.eclipse.sisu.plexus.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    13350 Nov  7  2019 plexus‑cipher‑1.7.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 plexus‑cipher.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff     4225 Nov  7  2019 plexus‑component‑annotations‑2.1.0.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 plexus‑component‑annotations.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    85327 Nov  7  2019 plexus‑interpolation‑1.25.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 plexus‑interpolation.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    27703 Nov  7  2019 plexus‑sec‑dispatcher‑1.4.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 plexus‑sec‑dispatcher.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   261801 Nov  7  2019 plexus‑utils‑3.2.1.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 plexus‑utils.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    41424 Nov  7  2019 slf4j‑api‑1.7.29.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff     1224 Nov  7  2019 slf4j‑api.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11586 Nov  7  2019 wagon‑file‑3.3.4.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff  2206349 Nov  7  2019 wagon‑http‑3.3.4‑shaded.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    55776 Nov  7  2019 wagon‑provider‑api‑3.3.4.jar

All files which are like maven‑core.. etc. are containing the version number of Maven (3.6.3) also the problematic

‑rw‑r‑‑r‑‑   1 khmarbaise  staff  2591373 Nov  7  2019 guava‑25.1‑android.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 guava.license
‑rw‑r‑‑r‑‑   1 khmarbaise  staff   520662 Nov  7  2019 guice‑4.2.1‑no_aop.jar
‑rw‑r‑‑r‑‑   1 khmarbaise  staff    11560 Nov  7  2019 guice.license

You see that this is in particular different to the given output you have where only file:/usr/share/maven/lib/guice‑4.2.1‑no_aop.jar apart from the missing version number of the other artifacts.

That means the problem is based on the usage of Ubuntu Maven and NOT using Apache Maven which is compatible with JDK 7 where as the repackaged version of Ubuntu is simply not.

The simplest solution is to remove the ubuntu Package of Maven and install the original Apache Maven https://maven.apache.org/download.cgi then the build with JDK 7 will work. (Download and check the checksums etc.)

Also you can download the Apache Maven and check the checksums of files against the ones of your distro (/usr/share/maven/lib/) I bet that all files are different.

The issue is based on the idea of distros to repackage Application (for example Maven) with their dependencies which are on their system which in reality means you have different versions of dependencies which results in such issues.

(by jqnokhmarbaise)

參考文件

  1. Can't run Maven 3.6.3 on JDK7 (CC BY‑SA 2.5/3.0/4.0)

#maven-3 #java #java-7 #maven






相關問題

Maven <include> wildcard cocok dengan nama folder parsial (Maven <include> wildcard match on partial folder name)

Eclipse 中使用 MAVEN 3.04 的動態 Web 應用程序 (Dynamic web application in eclipse using MAVEN 3.04)

Множныя рэпазітары Maven3 (Maven3 multiple repos)

замена ўласцівасці архетыпа maven (maven archetype property substitution)

Maven 發布和版本 Maven 插件 (Maven release and versions maven plugin)

Maven-glassfish-plugin:如何指定部署目標? (Maven-glassfish-plugin: how to specify deploy target?)

在 Maven WAR 構建中添加其他類 (Adding Additional classes in maven WAR build)

分佈式 Jenkins - Linux 上的主控和 Windows 上的從屬 - 如何配置節點特定設置 (Distributed Jenkins- Master on Linux and slave on windows- How to configure node specific setting)

如何觸發Maven SCM插件根據現有目錄自動切換目標? (How to trigger Maven SCM plugin to automatically switch goals based on existing directory?)

使用 MongoDB 存儲數據的 Java 應用程序是否需要 Maven? (Is Maven necessary for a Java application that uses MongoDB to store data?)

“el-api”在 pom.xml 中什麼時候有用? (When is "el-api" useful in pom.xml?)

無法在 JDK7 上運行 Maven 3.6.3 (Can't run Maven 3.6.3 on JDK7)







留言討論