13

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>
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • There will be created a bounty of 500 points when I am allowed to. If problem is solved before that, bounty will go to that answer. – Thorbjørn Ravn Andersen Dec 18 '18 at 14:22
  • so why its failing on 11 - because in 11 java javaFX no longer part of JDK, but standalone module. I think you can add it with maven and check if this helps. And why it`is missing - it may be some transitive dependency? may you share you build file – Alex G. Dec 18 '18 at 14:30
  • 2
    @ThorbjørnRavnAndersen You've got to share what your current `mumble-data-service-parent` module's `pom.xml` looks like. That's where one can start finding the cause. Also, if it has a `parent`, that might be bringing in something along with dependency management as well. Or possibly a link to the project/MCVE to reproduce the error you'd just stated would improve the question further. – Naman Dec 18 '18 at 14:37
  • Stackoverflow will unfortunately not let me attach the output from help:effective-pom to the question :-/ – Thorbjørn Ravn Andersen Dec 18 '18 at 14:51

2 Answers2

16

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.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • I am aware that JavaFX is no longer part of the JDK. To my understanding our modules does not reference javafx so I don't understand why Maven wants to pull it in. A dependency might reference it though but "mvn dependency:tree" which works with Java 10 does not mention neither javafx nor openjfx. So I have no idea where to do the suggested change. – Thorbjørn Ravn Andersen Dec 18 '18 at 14:37
  • @ThorbjørnRavnAndersen Try `mvn help:effective-pom` to see the runtime `pom.xml`, Maybe it's a dependency of a plugin? It's impossible to debug this without seeing your effective `pom.xml`. – Karol Dowbecki Dec 18 '18 at 14:39
  • 3
    @ThorbjørnRavnAndersen could be `org.hibernate.validator:hibernate-validator:jar:6.0.11.Final:compile` as per [HV-1644 Using Hibernate Validator with Java 11 brings JavaFX on the classpath](https://hibernate.atlassian.net/browse/HV-1644). Please add your `pom.xml`. – Karol Dowbecki Dec 18 '18 at 14:44
  • I cannot attach the output from help:effective-pom as stackoverflow fails when trying to save the very large edit and I don't have an immediate place to put it instead. However that exact hibernate dependency is in there (probably pulled in by spring boot). I will have a closer look. Thanks for now. – Thorbjørn Ravn Andersen Dec 18 '18 at 14:53
  • Your deduction was correct. I have accepted your answer. If the bounty is not awarded within the next days, please remind me. – Thorbjørn Ravn Andersen Dec 18 '18 at 15:03
  • Great help.. I was stuck at this for a week... thanks – Learner May 14 '20 at 03:48
3

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>
Adi Wehrli
  • 31
  • 2
  • There is some commentary about this issue upstream in the Confluent library that brings in hibernate-validator: https://github.com/confluentinc/rest-utils/issues/170 – Sean Glover Feb 10 '20 at 16:26