3

I'm using v3.7.0 of the plugin as required and JDK 9.0.1. I have added two requires statements, each referring to a jar in the class path (automatic module). The module-info.java compiles successfully in Eclipse after I moved the jars to Modulepath. However, Maven gives me a compiler error saying one of them is missing (strangely, not the first one which is just one line before). I tried to check the automatic module name but I get an error from the commands just for this jar. What does this error mean and how do I fix it so that I can discover the proper module name?

I replaced my username in the output below. The jar in question does use a ServiceLoader but is not compiled with Java 9.

computerName:Commander-java username$ jar --file=/Users/username/.m2/repository/com/username/rcf/1.0/rcf-1.0.jar --describe-module
Unable to derive module descriptor for: /Users/username/.m2/repository/com/username/rcf/1.0/rcf-1.0.jar
Provider class com.username.rcf.server.TestCmdChain not in module

computerName:Commander-java username$ java -p /Users/username/.m2/repository/com/username/rcf/1.0/rcf-1.0.jar --list-modules
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /Users/username/.m2/repository/com/username/rcf/1.0/rcf-1.0.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class com.username.rcf.server.TestCmdChain not in module

The answer in How to deal with java keywords in auto generated module names in Java 9? has a different error related to using a Java identifier in the module name. The automatic jar name for my module should just be rcf since the jar name is rcf-1.0.jar. The error I'm getting is different also.

GabeV
  • 859
  • 8
  • 21
  • Possible duplicate of [How to deal with java keywords in auto generated module names in Java 9?](https://stackoverflow.com/questions/46501388/how-to-deal-with-java-keywords-in-auto-generated-module-names-in-java-9)... Do you own the artifact `rcf-1.0.jar`? – Naman Oct 23 '17 at 01:52
  • Yes I do own it. I don’t have any Java identifiers in the name. It’s just rcf. The error seems to have to do with the ServiceLoader because the class mentioned in the error implements an interface that is used with ServiceLoader, but not sure. Can’t make sense of it. – GabeV Oct 23 '17 at 02:54
  • 1
    Retracted duplicate vote. Ya seems like the implementation package [doesn't reside in the module](https://stackoverflow.com/a/46881513/1746118) itself. – Naman Oct 23 '17 at 03:25

1 Answers1

4

While deriving module description the contents of any META-INF/services configuration files are mapped to provides declarations.

The packages scanned for the services are the ones containing class files.

Also, the package name for individual classes is derived from their fully qualified name. From the shared logs com.username.rcf.server shall be the expected package name for the service to be provided and this shall turn into

provides x.y.z.TestCmdChainInterface with com.username.rcf.server.TestCmdChain

Seems like there is no such package com.username.rcf.server existing in your module.

Naman
  • 27,789
  • 26
  • 218
  • 353