Missing dependencies when generate-module-info jdeps
Asked Answered
E

1

13

I`m trying to run jdeps with the following command:

jdeps --module-path modules --generate-module-info out com.demo.market.jar

My com.demo.market.jar depends both on application modules and automatic modules. I put all dependencies in the 'modules' folder but I got an error:

Error: missing dependencies
com.demo.market.platform.MarketPlace ->  com.demo.client.wholesale.Client  not found
com.demo.market.platform.MarketPlace ->  com.demo.product.api.Product      not found
com.demo.market.platform.MarketPlace ->  com.demo.product.laptop.Laptop    not found
com.demo.market.collector.ProductsCollector -> com.demo.logistic.DeliveryService not found
com.demo.market.collector.ProductsCollector -> com.demo.product.api.Product      not found

But when I add --add-modules It works fine.

jdeps --module-path modules --add-modules com.demo.client,com.demo.product,com.demo.logistic --generate-module-info out com.demo.market.jar

Am I doing something wrong? I supposed that jdeps would find all modules instead of manually add them.

Erida answered 26/11, 2017 at 20:7 Comment(1)
Does jdeps --generate-module-info out com.my.app.jar simply not work for you? What's your path and what modules does it include. Could you share the details for both the command --module-path and --add-modules as used by you?Rebekahrebekkah
R
8

When you execute the following:

jdeps --module-path modules --generate-module-info out com.demo.market.jar

The modules that are resolved from the directory are observable modules which in your case are not able to make it to the set of root modules.


Over the other part of the question -

jdeps --module-path modules --add-modules com.demo.client,com.demo.product,com.demo.logistic --generate-module-info . com.demo.market.jar

While on the other hand, adding them explicitly makes sure the modules are present in the set of root modules.


As an alternative(from the JEP261#Module System, you can try using the command

jdeps --module-path modules --add-modules=ALL-MODULE-PATH --generate-module-info out com.demo.market.jar 

As a final special case, at both run time and link time, if is ALL-MODULE-PATH then all observable modules found on the relevant module paths are added to the root set. ALL-MODULE-PATH is valid at both compile time and run time. This is provided for use by build tools such as Maven, which already ensure that all modules on the module path are needed. It is also a convenient means to add automatic modules to the root set.


Side note there, in terms of the commands to be executed:-

  • Also, the jdeps output shared in the question holds true with -verbose:class ideally.
Rebekahrebekkah answered 27/11, 2017 at 13:28 Comment(11)
adding ALL-MODULE-PATH solved the issue. Thanks. But for me still not clear when I can use just jdeps --generate-module-info out com.my.app.jarErida
@ZimboRodger Its useful when you lets say migrate an existing jar to Java9 modules and add to it the module-info.java as descriptor.Rebekahrebekkah
I mean what should I do to use this command without specifying --module-path as you mentioned in your very first commentErida
The module path is to make sure all the modules that your current artifact depend on are resolved while generating the module-info. The path to look for additionally.Rebekahrebekkah
@Naman, ty for useful information. I tried your solutions, but I'm still getting not found for all dependencies inside selenium-chrome-driver.jar legacy jar, but for selenium-api.jar it works fine, yes.Postage
@Postage You've got to make sure the modules that it's referring to are present on the module path to ensure they are resolved during the generation.Rebekahrebekkah
@Naman, how to check it correctly? To add each dependency manually via --add-modules as in 2nd line of your answer? I'm getting also not found in any cases. E.g. If I write: --module-path modules --add-modules org.openqa.selenium.chrome.ChromeOptions --generate-module-info ...\selenium selenium-chrome-driver-3.141.59.jar I get: Exception in thread "main" java.lang.module.FindException: Module org.openqa.selenium.chrome.ChromeOptions not foundPostage
@Postage The problem there looks in --add-modules org.openqa.selenium.chrome.ChromeOptions which is where you need to specify the module that includes the class ChromeOptions and not the complete class itself.Rebekahrebekkah
@Naman, corrected it to jdeps --module-path modules --add-modules org.openqa.selenium.chrome --generate-module-info C:\...\selenium selenium-chrome-driver-3.141.59.jar the same issue. And tried by the same logic, but instead of org.openqa.selenium.chrome I wrote this org.openqa.selenium as one level higher also Exception in thread "main" java.lang.module.FindException: Module org.openqa.selenium not foundPostage
@Naman, using ALL-MODULE-PATH option, I get a lot of "not found".Postage
It is hard to make sense of this answer. The observable modules do not "make it" into the root set. From what I understand, the root set is given, and the very job of jdep is to construct a dependency graph for it from the observable set. The error would only make sense if the dependencies actually absent from the module-path. And then add-modules seem to break this presence check.Genitive

© 2022 - 2024 — McMap. All rights reserved.