Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes Maven want openjfx with Zulu Java 11 and not Zulu Java 8 for a Spring Boot project?

I have inherited a Spring Boot project where we would like to use Java 11 for testing due to the nice features added in Java 9 and 10 (var and List.of(...)).

The Maven project is split up in several parts where the code for production is set up for Java 8, and the test code for Java 11. This works nicely individually on module basis and the global build works with Java 8 (except for the tests failing to compile) and Java 10.

Now I want to compile everything from the root using Java 11 due to this being the LTS (Zulu as this is on Windows 10), and for some reason Maven now wants to pull in org.openjfx:javafx.base:jar:11.0.0-SNAPSHOT

[INFO] Building mumble-data-service-parent 1.0.0-SNAPSHOT              
[1/8]
[INFO] --------------------------------[ pom ]---------------------------------
[WARNING] The POM for org.openjfx:javafx.base:jar:11.0.0-SNAPSHOT is missing, no dependency information available
[INFO]

As the dependencies are not satisfied I cannot (at least not in a way I can think of) get Maven to tell me why it wants to do this so I have no idea where to look, and the project does not appear to reference javafx in the first place (being a Spring Boot microservice that would surprise me a bit). Hence this question.

What causes it, and how do I fix it?


As correctly deduced by Karol this issue was seen before and the fix was to upgrade the hibernate validator dependency to a newer version. All that was needed for me was to add the following property to my parent pom:

    <!-- needed for building with Java 11 -->
    <hibernate-validator.version>6.0.12.Final</hibernate-validator.version>
like image 783
Thorbjørn Ravn Andersen Avatar asked Dec 18 '18 14:12

Thorbjørn Ravn Andersen


People also ask

How to use Maven plugin for JavaFX?

Maven plugin for JavaFX 1 Install. The plugin is available via Maven Central. 2 Usage. Create a new Maven project, use an existing one like HelloFX, or use an archetype. The project can be modular or... 3 Issues and Contributions. Issues can be reported to the Issue tracker. Contributions can be submitted via Pull requests... More ...

Which version of Spring Boot is compatible with Java 11?

Upgrade the spring boot version to 2.1.X since 2.0.X and older versions does not support Java 11. In our project, we have gone for 2.3.4.RELEASE version. Upgrading the spring boot to 2.3.4.RELEASE will also upgrade its corresponding dependencies like Click here to find the complete list of dependencies and its compatible versions.

How to build a Maven project with JDK 11?

In case you want to build and install the latest snapshot, you can clone the project, set JDK 11 and run Create a new Maven project, use an existing one like HelloFX, or use an archetype. The project can be modular or non-modular.

What version of Maven should I upgrade to 11?

If you are using the older version of maven, upgrade it the latest version and also update the source and target to 11. 3. Spring Boot Upgrade the spring boot version to 2.1.X since 2.0.X and older versions does not support Java 11. In our project, we have gone for 2.3.4.RELEASE version.


2 Answers

This could be caused by HV-1644 Using Hibernate Validator with Java 11 brings JavaFX on the classpath if org.hibernate.validator:hibernate-validator:jar:6.0.11.Final is part of your dependencies. Updating to 6.0.12 or newer should solve it.

like image 81
Karol Dowbecki Avatar answered Oct 08 '22 16:10

Karol Dowbecki


Recently I ran into the same problem with building an artifact using Maven with JDK 11. Some dependency was specified to use the artifact org.openjfx:javafx.base:11.0.0-SNAPSHOT (JavaFX, which is no more part of Java 11). So Maven always wanted to download this artifact, which - in fact - did not exist in our Maven repository. So building subsequently failed as did analyzis of the dependency tree. I could not determine, where this artifact would be used.

I googled for this artifact's usages and found this bug issue in Maven JIRA about Hibernate: Dependency resolution broken with Java 11 (MNG-6500).

There it is said that in Hibernate 6.0.11 this artifact was specified in the POM of org.hibernate.validator:hibernate-validator:6.0.11.Final. But I was not aware of any usage of this Hibernate dependency within my project. I searched the whole local Maven repository for this artifact. And what a surprise, the mentioned Hibernate artifact was used by org.glassfish.jersey.ext:jersey-bean-validation:jar:2.28 (which has a parent org.glassfish.jersey:project:2.28 in the parent chain where hibernate-validator's version is specified). And this dependency in turn was used by io.confluent:kafka-schema-registry:jar:5.4.0.

So the only thing I had to do is to exclude this JavaFX artifact from io.confluent:kafka-schema-registry:jar:5.4.0 dependency:

<dependency>
    <groupId>io.confluent</groupId>
    <artifactId>kafka-schema-registry</artifactId>
    <version>5.4.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx.base</artifactId>
        </exclusion>
    </exclusions>
</dependency>
like image 3
Adi Wehrli Avatar answered Oct 08 '22 15:10

Adi Wehrli