I'm trying to run jlink on a hello world Spring Boot Web MVC app (not using the fat jar). It doesn't work, neither with Tomcat nor Jetty, in both cases because the module graphs appear to be structurally invalid despite that every JAR is a module.
In Tomcat's case, there's a module-info.class that contains dependencies on module names that aren't JPMS compliant (they have a dash in them). Filed:
https://bz.apache.org/bugzilla/show_bug.cgi?id=66438
So I figured, OK, I'll try with Jetty. But that also doesn't seem to be valid. Some of the modules have a requires transitive clause on jetty.servlet.api but none of the JARs (brought in by gradle) appear to export that module.
Is this an expected state of affairs? My understanding had been that 'modern' Spring Boot apps were compatible with JPMS so I can't tell if these are bugs or if I'm doing something wrong.
Easy way to reproduce:
- Create a program
demoserver - Add the
applicationgradle plugin, runinstallDistto get a libs directory with all the JARs on it. cd build/install/demoserver/lib- Run
java -p . --add-modules=ALL-MODULE-PATH -m demoserver/com.example.demoserver.DemoserverApplicationKt
... or moral equivalent.
Result:
java.lang.module.FindException: Module jetty.servlet.api not found, required by org.eclipse.jetty.servlets
Expected result: it runs successfully.
Comment From: wilkinsona
Some of the modules have a requires transitive clause on jetty.servlet.api but none of the JARs (brought in by gradle) appear to export that module.
We prefer to use the official Servlet API artifacts so we exclude the Jetty-specific artifacts in favor of those. If you want to use Jetty on the module path, you will have to reverse this exclusion and replacement process.
Please note that, in our opinion, the module path provides minimal benefit to Spring Boot applications so it is low priority for us. You should be able to get it to work but it may require some effort on your part.