spring-boot
spring-boot copied to clipboard
Spring Boot Maven plugin AOT cannot handle Maven modules with module-info.java
When native compiling a Maven module which is Java Module - aka it contains module-info.java, for example:
module org.somecomany.somepackage.apps.commandline {
exports org.somecomany.somepackage.utils;
exports org.somecomany.somepackage.handlers;
requires java.net.http;
requires transitive java.xml;
// logging
requires org.slf4j;
// spring
requires spring.core;
requires spring.beans;
requires spring.context;
requires transitive spring.boot;
requires spring.boot.autoconfigure;
// to let Spring and Test framework access non public members
opens org.matihost.learning.java to spring.core, spring.beans, spring.context, org.mockito;
opens org.somecomany.somepackage.beans to spring.core, spring.beans, spring.context, org.mockito;
opens org.somecomany.somepackage.handlers to spring.core, spring.beans, spring.context, org.mockito;
}
the following error is happening:
20:00:48.645 [main] [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project command-line: Unable to compile generated source
20:00:48.645 [main] [ERROR] module not found: spring.boot.autoconfigure
20:00:48.645 [main] [ERROR] module not found: spring.boot
20:00:48.645 [main] [ERROR] module not found: spring.context
20:00:48.645 [main] [ERROR] module not found: spring.beans
20:00:48.645 [main] [ERROR] module not found: spring.core
20:00:48.645 [main] [ERROR] module not found: org.slf4j
20:00:48.645 [main] [ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project command-line: Unable to compile generated source
module not found: spring.boot.autoconfigure
module not found: spring.boot
module not found: spring.context
module not found: spring.beans
module not found: spring.core
module not found: org.slf4j
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to compile generated source
module not found: spring.boot.autoconfigure
module not found: spring.boot
module not found: spring.context
module not found: spring.beans
module not found: spring.core
module not found: org.slf4j
at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:107)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.IllegalStateException: Unable to compile generated source
module not found: spring.boot.autoconfigure
module not found: spring.boot
module not found: spring.context
module not found: spring.beans
module not found: spring.core
module not found: org.slf4j
at org.springframework.boot.maven.AbstractAotMojo.compileSourceFiles (AbstractAotMojo.java:154)
at org.springframework.boot.maven.ProcessAotMojo.executeAot (ProcessAotMojo.java:95)
at org.springframework.boot.maven.AbstractAotMojo.execute (AbstractAotMojo.java:104)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
When module-info.java is removed - the native compilation moves on successfully.
Can you please explain why you're trying to use module-info.java
when compiling to a native image? As far as we are aware, there are no benefits to using the module path in this situation.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Just practical reason. There is already existing Java module with value module-info.java - so spring boot maven plugin could just ignore it during compilation - otherwise somebody just need to trick to remove it before compilation to native mode...
On the other hand, ff something contains module-info.java - from Java standpoint perspective it is sealed also during compile time - from encapsulation perspective Jigsaw module brings similar benefits to native compilation... but I don't want to open yet another discussion about Java modules sense... Years of Jigsaw vs OSGi made more hurt than benefits in my opinion... So just practical reasoning here :)
Existing projects that happen to use modules will be discouraged from trying native images I suppose. Some will probably work just fine if they just remove the module-info.java
, but for some apps it's not that simple - there might be annotations in the module info, for instance.
I also occured this problem ,is there any plan to fix this problem?
We have no plans at this time. JPMS appears to bring few, if any, benefits to the vast majority of Spring Boot's users. As such, it's low priority for us as time spent elsewhere will have much broader benefits to the community as a whole.
Wouldn't it at least be possible to ignore the module-info if it is present? This would make it easier for people making both regular java builds and native builds that can't simply delete the module-info.
We'd like to understand the problem a bit better and see what our options are. Can someone please share a small sample we can run ourselves that breaks the way it's been described? You can share it with us by attaching a zip here or push the code to a GitHub repository.
Edit: scratch that, @wilkinsona provided a small sample.
I think any app with a module-info.java
would break. Here's a sample (lifted from the JStachio project): https://github.com/dsyer/jstachio-spring-example.