「Maven」- 常见问题处理

… package com.sun.javafx.binding does not exist …

Specify JDK for Maven to use
Java Development Kit for ARM Release Notes 8 Update 33
Wikipedia/JavaFX
Removed from JDK 11, JavaFX 11 arrives as a standalone module
JavaFX will be removed from the Java JDK
Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?

在进行 Jenkins 构建时,产生如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project foo-manage: Compilation failure: Compilation failure:
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/third/util/Validator.java:[8,29] error: package com.sun.javafx.binding does not exist
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/utils/app/Configurations.java:[4,26] error: package com.sun.javafx.geom does not exist
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/utils/msg/MessageCategory.java:[3,29] error: package com.sun.javafx.binding does not exist
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/third/util/Validator.java:[113,15] error: cannot find symbol
[ERROR]  class Validator
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/utils/app/Configurations.java:[46,22] error: cannot find symbol
[ERROR]  class Configurations
[ERROR] /var/lib/jenkins/workspace/foo-manage_test/src/main/java/com/foo/manage/utils/msg/MessageCategory.java:[71,15] error: cannot find symbol
[ERROR] -> [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/MojoFailureException

主要的错误信息是:error: package com.sun.javafx.binding does not exist

问题原因

系统环境:CentOS Linux release 7.4.1708 (Core)

运行环境:openjdk version “1.8.0_191”

解决办法

虽然移除了,但是 java version “1.8.0_66″中还是有 jre/lib/ext/jfxrt.jar 这个包的。所以修改了 JAVA_HOME 与 PATH 环境变量,使用特定的 Java 版本来构建这个项目。

!!!其实,正常一点的做法是调整程序代码。

其是什么时候移除的

我们没有找到具体是在哪个版本移除的。但是,有别人写的文章、维基百科做参考:

Starting with JDK 8u33, JavaFX Embedded is removed from the ARM bundle and is not supported.

Oracle is removing JavaFX from the Java Development Kit (JDK) 11, given an overall desire to pull out noncore modules from the JDK and retire them or stand them up as independent modules.

JavaFX will be removed from the Java JDK as of JDK 11, which is due in September 2018. It is bundled in the current JDK 9 and will remain in JDK 10, due this spring. Commercial support for JavaFX in JDK 8 will continue through at least 2022. Featuring a set of packages for graphics and media, JavaFX has been part of the JDK download since 2012.

反正从 Java 8 开始,就已经有了删除的迹象。

相关链接

# 在 Debian 中,有 openjfx 包 | Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?

… Could not transfer artifact … Blocked mirror for repositories …

我们使用 Maven 3.9.9 版本,但是执行 Mavne 构建时,提示如下错误:

Non-resolvable parent POM for XXXXXXX: The following artifacts could not be resolved: XXXXXXX (absent): Could not transfer artifact XXXXXXX from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [XXXXXXX-public (http://XXXXXXX/repository/maven-public/, default, releases+snapshots)] and ‘parent.relativePath’ points at no local POM @ line 7, column 13 -> [Help 2]

根据网络上检索到的信息,可能原因是 Maven 3.9.9 不再执行 HTTP 类型的 Maven 仓库,需要 HTTPS 类型的 Maven 仓库。

我们尝试增加如下配置,但是并未生效。

<mirrors>
  <mirror>
    <id>allow-http-XXXXXXX</id>
    <mirrorOf>!XXXXXXX-public</mirrorOf> <!-- Exclude XXXXXXX-public from blocking,名称要对应--> 
    <name>Allow HTTP for XXXXXXX Repo</name>
    <url>http://0.0.0.0/</url> <!-- Dummy URL, not used -->
  </mirror>
</mirrors>

<repositories>
  <repository>
    <id>XXXXXXX-public</id>
    <url>http://XXXXXXX/repository/maven-public/</url>
  </repository>
</repositories>

针对我们的场景,修改 Nexus 部署以提供 HTTPS 访问并不可行,所以我们直接退回 3.6.3 版本,先解决问题。