Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Maven plugin AOT cannot handle Maven modules with module-info.java #33383

Closed
matihost opened this issue Nov 27, 2022 · 9 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@matihost
Copy link

matihost commented Nov 27, 2022

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2022
@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 28, 2022
@spring-projects-issues
Copy link
Collaborator

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.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Dec 5, 2022
@matihost
Copy link
Author

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 :)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Dec 10, 2022
@dsyer
Copy link
Member

dsyer commented Jan 4, 2023

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.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Jan 18, 2023
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided for: team-meeting An issue we'd like to discuss as a team to make progress labels May 11, 2023
@philwebb philwebb added this to the 3.0.x milestone May 11, 2023
@philwebb philwebb modified the milestones: 3.0.x, 3.1.x Nov 8, 2023
@xurui8691413
Copy link

I also occured this problem ,is there any plan to fix this problem?

@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.2.x May 20, 2024
@janeisklar
Copy link

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.

@snicoll

This comment was marked as outdated.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 29, 2024
@snicoll snicoll self-assigned this Jul 29, 2024
@dsyer
Copy link
Member

dsyer commented Jul 29, 2024

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.

@snicoll snicoll removed this from the 3.2.x milestone Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

8 participants