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.

  • 3
    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? – Naman Nov 27 '17 at 01:13

1 Answers1

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.
Naman
  • 27,789
  • 26
  • 218
  • 353
  • 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.jar` – David stands with Ukraine Nov 28 '17 at 08:15
  • 1
    @ZimboRodger Its useful when you lets say migrate an existing jar to Java9 modules and add to it the `module-info.java` as descriptor. – Naman Nov 28 '17 at 08:16
  • I mean what should I do to use this command without specifying `--module-path` as you mentioned in your very first [comment](https://stackoverflow.com/questions/47500529/missing-dependencies-when-generate-module-info-jdeps/47512109?noredirect=1#comment81961276_47500529) – David stands with Ukraine Nov 28 '17 at 08:21
  • 1
    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. – Naman Nov 28 '17 at 09:00
  • @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. – invzbl3 Aug 11 '19 at 23:24
  • @invzbl3 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. – Naman Aug 12 '19 at 06:11
  • @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 found` – invzbl3 Aug 12 '19 at 11:33
  • @invzbl3 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. – Naman Aug 12 '19 at 12:24
  • @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 found` – invzbl3 Aug 12 '19 at 12:36
  • @Naman, using ALL-MODULE-PATH option, I get a lot of "not found". – invzbl3 Aug 12 '19 at 12:49
  • 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. – Андрей Вахрушев Nov 12 '21 at 15:09