Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modules A and B export package some.package to module C in Java 9

Tags:

I have three modules module-a, module-b and module-c. When I run my application I get the following:

Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules module-a and module-b export package some.package to module module-c

What does it mean, taking into consideration that module-c doesn't import some.package and how to fix it?

like image 603
Pavel_K Avatar asked Sep 18 '17 10:09

Pavel_K


1 Answers

Looks like you've created a split package, meaning two modules (module-a and module-b in your case) contain the same package (some.package). The module system does not allow that. If you place both modules on the module path, you will get this error regardless of whether the package is exported or whether a third module depends on the other two.

The fix is, not to create modules that share the same package. This is not only a technical solution, it also improves the design by making sure each module has a specific and unique API.

like image 186
Nicolai Parlog Avatar answered Sep 18 '22 21:09

Nicolai Parlog