Java "module X does not read module Y" (JPMS) - Fix in CI
Under the Java Platform Module System, a module can only use types from modules it explicitly reads. Your module-info.java is missing a requires for a module whose types your code uses, so compilation (or launch) fails.
What this error means
javac fails with module com.example.app does not read module com.fasterxml.jackson.databind, or the equivalent at runtime. The type is on the module path but not readable because no requires declares the edge.
src/main/java/module-info.java:1: error: module com.example.app does not
read module com.google.gson
Gson gson = new Gson();
^
1 errorCommon causes
Missing requires directive
Your module uses a type from another module but module-info.java does not declare requires that.module.
Wrong module name
The requires uses the jar name rather than the actual module name (automatic module name differs from the artifact id).
Transitive readability not propagated
A dependency exposes a type from a third module in its API but did not declare requires transitive, so you cannot read it implicitly.
How to fix it
Add the requires directive
Declare the module your code reads.
module com.example.app {
requires com.google.gson; // now readable
}Use the correct module name
Find the real module name rather than guessing from the jar.
jar --describe-module --file gson-2.11.0.jar
# prints the module name to put in requiresRequest transitive readability where appropriate
If your module re-exposes a type in its own API, use requires transitive.
module com.example.app {
requires transitive com.google.gson;
}How to prevent it
- Keep
module-info.javain sync with the types each module actually uses. - Resolve module names with
jar --describe-module, not the jar filename. - Use
requires transitiveonly when re-exposing a type in your API.