0

I'm having trouble getting a Maven Eclipse project to build in both Maven and Eclipse. The problem appears to be that the JSON validation library com.networknt wants to be required (in module-info.java) as requires com.networknt.schema in Maven, but as requires json.schema.validator in Eclipse (as Maven project). Each build simply cannot see the module if it is named the other way. I can build in Eclipse if I "run as maven build..." but that doesnt help coding or JUnit test debug etc.

I have the following in my pom:

<dependency>
  <groupId>com.networknt</groupId>
  <artifactId>json-schema-validator</artifactId>
  <version>1.4.3</version>
</dependency>

I'm using 1.4.3 from https://mvnrepository.com/artifact/com.networknt/json-schema-validator

Anyone know what's up here?

5
  • 1
    com.networknt:json-schema-validator:1.4.3 is a multi-release JAR with the module-info.class not included in the root of the JAR, but as META-INF/versions/9/module-info.class. The module-info.class is compiled as Java 9 bytecode, the rest as Java 8 bytecode. Eclipse seems not support this. For details and a workaround see my comment here.
    – howlger
    Commented Jul 8 at 18:02
  • Eclipse can not support that (and shouldn't), because the module-info.class must be located in the root of the jar file... Also I would check the most recent version of that: central.sonatype.com/artifact/com.networknt/… version 1.5.0 that's issue of the json-schema-validator jar ... or the project behind it... Created an issue for the project: github.com/networknt/json-schema-validator/issues/1089
    – khmarbaise
    Commented Jul 8 at 18:35
  • @howlger - that's exactly it! The workaround worked as well - thanks! Can you create your reply as an answer so I can accept it please :)
    – fig
    Commented Jul 8 at 18:50
  • PS No idea why someone downvoted me over an issue in Eclipse, but whatever.
    – fig
    Commented Jul 8 at 18:51
  • 1
    @khmarbaise As far as I understand, JEP 238 allows the module descriptor module-info.class located only in META-INF/versions/9 and not in the root: "A multi-release modular need not have a module descriptor at the located root. In this respect a module descriptor would be treated no differently to any other class or resource file. This can ensure that, for example, only Java 8 versioned classes are present in the root area while Java 9 versioned classes (including the module descriptor) are present in the 9 versioned area."
    – howlger
    Commented Jul 9 at 5:49

1 Answer 1

1

The json-schema-validator-1.4.3.jar is a multi-release JAR file with the module-info.class not included in the root of the JAR, but as META-INF/versions/9/module-info.class. The module-info.class file is compiled with Java 9 and the rest with Java 8. This way it can be used with Java 8, but also as a modular JAR with Java 9 and higher.

Eclipse seems not to support this yet: Eclipse JDT core issue #2495: Multi-Release JAR is not recognized as such

As a workaround, do one of the following:

  • In the json-schema-validator-1.4.3.jar copy module-info.class from META-INF/versions/9/ to the root
  • In META-INF/MANIFEST.MF add the line Automatic-Module-Name: com.networknt.schema

Not the answer you're looking for? Browse other questions tagged or ask your own question.