spring-projects-experimental / spring-boot-migrator

Spring Boot Migrator (SBM) is a tool for automated code migrations to upgrade or migrate to Spring Boot
Apache License 2.0
431 stars 87 forks source link

Multi-module handler fails when scanning a project that has only one module #988

Open Loloweb opened 8 months ago

Loloweb commented 8 months ago

Describe the bug On a Maven multi-module environment project that only contains one module, when trying to apply the migrate-jax-ws recipe, the program returns an error :

Applying recipe 'migrate-jax-ws'
Action [AddDependencies] 'Add spring boot web-services starter' failed: Cannot invoke "org.springframework.sbm.engine.recipe.MultiModuleHandler.handle(org.springframework.sbm.engine.context.ProjectContext)" because "this.multiModuleHandler" is null

SBM Version tested with release v0.15.0 and when compiled from commit 504c658

SBM Application spring-boot-migrator with option gitSupportEnabled=false

To Reproduce Steps to reproduce the behavior:

  1. Scan project
  2. Apply migrate-jax-ws
  3. See error

Expected behavior A successful jax-ws to Spring Boot base Web-Service migration

Stacktrace

org.springframework.sbm.engine.recipe.ActionFailedException: Action [AddDependencies] 'Add spring boot web-services starter' failed: Cannot invoke "org.springframework.sbm.engine.recipe.MultiModuleHandler.handle(org.springframework.sbm.engine.context.ProjectContext)" because "this.multiModuleHandler" is null
    at org.springframework.sbm.engine.recipe.Action.applyWithStatusEvent(Action.java:43)
    at org.springframework.sbm.engine.recipe.Recipe.apply(Recipe.java:101)
    at org.springframework.sbm.engine.commands.ApplyCommand.execute(ApplyCommand.java:69)
    at org.springframework.sbm.shell.ApplyShellCommand.apply(ApplyShellCommand.java:70)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.shell.command.invocation.InvocableShellMethod.doInvoke(InvocableShellMethod.java:306)
    at org.springframework.shell.command.invocation.InvocableShellMethod.invoke(InvocableShellMethod.java:232)
    at org.springframework.shell.command.CommandExecution$DefaultCommandExecution.evaluate(CommandExecution.java:160)
    at org.springframework.shell.Shell.evaluate(Shell.java:208)
    at org.springframework.shell.Shell.run(Shell.java:140)
    at org.springframework.shell.jline.InteractiveShellRunner.run(InteractiveShellRunner.java:73)
    at org.springframework.shell.DefaultShellApplicationRunner.run(DefaultShellApplicationRunner.java:65)
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:752)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at org.springframework.sbm.SpringShellApplication.main(SpringShellApplication.java:27)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.sbm.engine.recipe.MultiModuleHandler.handle(org.springframework.sbm.engine.context.ProjectContext)" because "this.multiModuleHandler" is null
    at org.springframework.sbm.engine.recipe.MultiModuleAwareAction.applyInternal(MultiModuleAwareAction.java:39)
    at org.springframework.sbm.engine.recipe.Action.applyWithStatusEvent(Action.java:37)
    ... 28 more

Example Source code to replicate the issue (Optional) any Maven multi-module environment containing one module should be enough to replicate the issue image

Desktop (please complete the following information):

Additional context When applying the recipe after scanning the module instead of the whole project, the program asks you to provide the path to WSDL file for the service. Inputting anything (doesn't matter if it's valid or not) results in an error:

Error processing WSDL file '{path-to-wsdl}'. Cannot invoke "org.openrewrite.ExecutionContext.getMessage(String)" because "this.delegate" is null
Try entering file path again or press 'Enter' to cancel migrating this Web Service
fabapp2 commented 8 months ago

Hi @Loloweb thanks for reporting. I can't look into this at the moment but will keep it open for another day.