0x00 记录病例

在本地编译 jmc(JDK Mission Control)7.1 时,需要构建releng/third-party,由于某些条件的约束限制,不能在 maven 公共仓库中下载javax.mail:dsn:jar:1.4的jar包。

错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ mvn p2:site
...
[info] [JAR] jakarta.activation-1.2.1.jar
[info] Resolving artifact=[javax.mail:dsn:1.4] transitive=[true] source=[false]
Downloading: http://maven.aliyun.com/nexus/content/groups/public/javax/mail/dsn/1.4/dsn-1.4.pom
Downloading: http://repository.ops4j.org/maven2/javax/mail/dsn/1.4/dsn-1.4.pom
[WARNING] The POM for javax.mail:dsn:jar:1.4 is missing, no dependency information available
Downloading: http://maven.aliyun.com/nexus/content/groups/public/javax/mail/dsn/1.4/dsn-1.4.jar
Downloading: http://repository.ops4j.org/maven2/javax/mail/dsn/1.4/dsn-1.4.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:32 min
[INFO] Finished at: 2022-04-28T17:17:07+08:00
[INFO] Final Memory: 24M/344M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.reficio:p2-maven-plugin:1.3.0:site (default-cli) on project external-dependencies: Execution default-cli of goal org.reficio:p2-maven-plugin:1.3.0:site failed: java.lang.RuntimeException: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact javax.mail:dsn:jar:1.4 in alimaven (http://maven.aliyun.com/nexus/content/groups/public/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

0x01 拜师学艺

在 stackoverflow 以及 github 上找到如下方法:

1
2
3
4
Regarding to "https://stackoverflow.com/questions/53687816/dependency-javax-mailmail1-4-not-found", "javax.mail:dsn:jar:1.4" is not in maven public repo due to license restrictions.
Workaround, download "javax.mail:dsn:jar:1.4" from https://www.oracle.com/technetwork/java/javamail/index-138643.html and then install it to ur local repo via:

mvn install:install-file -Dfile= -DgroupId=javax.mail -DartifactId=dsn -Dpackaging=jar -Dversion=1.4

0x02 解决病症

https://www.oracle.com/java/technologies/javamail-releases.html页面找到JavaMail 1.4,有一行说明:

JavaMail API 1.4, you can find it here

点击 here跳转到javamail的api介绍页面,我们再次在页面中寻找javamaill1.4,注意页面上的黑体字:JavaMail API Release 1.4

图1 JavaMail API 文档

我们点击DOWNLOAD按钮进入下载页面下载javax.mail 1.4,下载过程可能需要登录Oracle官网。

为了方便,我直接把下载地址贴出来:https://download.oracle.com/otn-pub/java/javamail/1.4-fcs/javamail-1_4.zip

下载javamail-1_4.zip包后解压,我们进入lib目录,找到dsn.jar文件。

在该路径下打开命令行,执行maven的命令,将jar文件推送到本地仓库。

1
mvn install:install-file -Dfile=dsn.jar -DgroupId=javax.mail -DartifactId=dsn -Dpackaging=jar -Dversion=1.4

当我们看到如下消息输出,表示推送成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(base) ➜  lib mvn install:install-file -Dfile=dsn.jar -DgroupId=javax.mail -DartifactId=dsn -Dpackaging=jar -Dversion=1.4
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /Users/zhoujunwen/Downloads/javamail-1.4/lib/dsn.jar to /Users/zhoujunwen/.m2/repository/javax/mail/dsn/1.4/dsn-1.4.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.580 s
[INFO] Finished at: 2022-04-28T18:02:39+08:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------

0x03 健康检查

虽说,我们找到了解决问题的方法以及按照方法去做了,但是否起到治愈疾病,是否真正解决了问题,还有待检验。
文章开始说了,是在构建releng/third-party时,发生的问题。那么我们重新构建即可知道问题是否解决。

1
mvn clean p2:site

观察输出的日志,未发现异常,也未发现警告。我们从日志中搜搜发现,输出了dsn的信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(base) ➜  third-party git:(develop) ✗ mvn p2:site                                                                                                
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building external-dependencies 7.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- p2-maven-plugin:1.3.0:site (default-cli) @ external-dependencies ---
[info] Resolving artifact=[org.twitter4j:twitter4j-core:4.0.7] transitive=[true] source=[false]
[info] [JAR] twitter4j-core-4.0.7.jar
...
[info] Resolving artifact=[javax.mail:dsn:1.4] transitive=[true] source=[false]
[info] [JAR] dsn-1.4.jar
...
Generation completed with success [0 seconds].
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:18 min
[INFO] Finished at: 2022-04-28T18:04:13+08:00
[INFO] Final Memory: 42M/939M
[INFO] ------------------------------------------------------------------------

到此,问题解决,大功告成!