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
451 stars 89 forks source link

"tree.starImportScope" is null #1038

Open fopnet opened 9 months ago

fopnet commented 9 months ago

Describe the bug running spring-boot-upgrade.jar using recommended command !

SBM Version spring-boot-migrator v0.15.0

SBM Application

com.mycompany commons 2.1.1

To Reproduce java -jar --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED spring-boot-upgrade.jar .

Expected behavior No nullpointer exception error

Screenshots If applicable, add screenshots to help explain your problem.

Stacktrace ... 33 common frames omitted Failed to execute ApplicationRunner java.lang.IllegalStateException: Failed to execute ApplicationRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:765) 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.SpringBootUpgradeReportApp.main(SpringBootUpgradeReportApp.java:31) 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.RuntimeException: This could be a broken jar. Activate logging on WARN level for 'org.openrewrite' might reveal more information. at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:44) at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:27) at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:270) at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputs(ReloadableJava17Parser.java:161) at org.openrewrite.java.Java17Parser.parseInputs(Java17Parser.java:38) at org.springframework.sbm.java.impl.RewriteJavaParser.parseInputs(RewriteJavaParser.java:64) at org.springframework.sbm.java.impl.RewriteJavaParser$$FastClassBySpringCGLIB$$93b26c14.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at org.springframework.sbm.java.impl.RewriteJavaParser$$EnhancerBySpringCGLIB$$fcaf02f.parseInputs() at org.springframework.sbm.project.parser.MavenProjectParser.parseMainJavaSources(MavenProjectParser.java:235) at org.springframework.sbm.project.parser.MavenProjectParser.parse(MavenProjectParser.java:126) at org.springframework.sbm.project.parser.ProjectContextInitializer.initProjectContext(ProjectContextInitializer.java:52) at org.springframework.sbm.engine.commands.ScanCommand.execute(ScanCommand.java:70) at org.springframework.sbm.SpringBootMigratorRunner.run(SpringBootMigratorRunner.java:48) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762) ... 13 more Caused by: org.openrewrite.java.JavaParsingException: Failed symbol entering or attribution ... 34 more Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null

Example Source code to replicate the issue (Optional) It would help us immensely if we were to have an example test source code or a snippet where you can see this problem, you could attach a zip file along with this issue.

Although this section is optional, it would speed up our process of providing a fix. P.S. Please remove any sensitive data and do not upload any proprietary source.

Desktop (please complete the following information): java17 Macos 12.5 Monterey

Additional context Add any other context about the problem here.

DivyaMaddipudi commented 3 months ago
                         org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:222)                    
                                 at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputs(ReloadableJava17Parser.java:151)                      
                                 at org.openrewrite.java.Java17Parser.parseInputs(Java17Parser.java:39)                                                    
                                 at org.openrewrite.Parser.parse(Parser.java:59)                                                                           

                         Caused by: java.lang.NullPointerException: Cannot invoke                                                                          
                         "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null                                
                                 at com.sun.tools.javac.comp.TypeEnter.ensureImportsChecked(TypeEnter.java:172)                                            
                                 at com.sun.tools.javac.comp.Enter.complete(Enter.java:627)                                                                
                                 at com.sun.tools.javac.comp.Enter.main(Enter.java:587)                                             

I'm also getting the same issue, Any help would be appreciated!!!

lucasoares commented 3 months ago

Same, for a custom multi-module project:

18:05:19.501 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:765)
        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.SpringBootUpgradeReportApp.main(SpringBootUpgradeReportApp.java:31)
        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:569)
        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.RuntimeException: This could be a broken jar. Activate logging on WARN level for 'org.openrewrite' might reveal more information.
        at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:44)
        at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:27)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:270)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputs(ReloadableJava17Parser.java:161)
        at org.openrewrite.java.Java17Parser.parseInputs(Java17Parser.java:38)
        at org.springframework.sbm.java.impl.RewriteJavaParser.parseInputs(RewriteJavaParser.java:64)
        at org.springframework.sbm.java.impl.RewriteJavaParser$$FastClassBySpringCGLIB$$93b26c14.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
        at org.springframework.sbm.java.impl.RewriteJavaParser$$EnhancerBySpringCGLIB$$d45f6298.parseInputs(<generated>)
        at org.springframework.sbm.project.parser.MavenProjectParser.parseTestJavaSources(MavenProjectParser.java:210)
        at org.springframework.sbm.project.parser.MavenProjectParser.parse(MavenProjectParser.java:163)
        at org.springframework.sbm.project.parser.ProjectContextInitializer.initProjectContext(ProjectContextInitializer.java:52)
        at org.springframework.sbm.engine.commands.ScanCommand.execute(ScanCommand.java:70)
        at org.springframework.sbm.SpringBootMigratorRunner.run(SpringBootMigratorRunner.java:48)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
        ... 13 common frames omitted
Caused by: org.openrewrite.java.JavaParsingException: Failed symbol entering or attribution
        ... 34 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null
        at com.sun.tools.javac.comp.TypeEnter.ensureImportsChecked(TypeEnter.java:172)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:627)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:587)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.enterAll(ReloadableJava17Parser.java:338)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:257)
        ... 33 common frames omitted
Failed to execute ApplicationRunner
java.lang.IllegalStateException: Failed to execute ApplicationRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:765)
        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.SpringBootUpgradeReportApp.main(SpringBootUpgradeReportApp.java:31)
        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:569)
        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.RuntimeException: This could be a broken jar. Activate logging on WARN level for 'org.openrewrite' might reveal more information.
        at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:44)
        at org.springframework.sbm.openrewrite.RewriteExecutionContextErrorHandler.accept(RewriteExecutionContextErrorHandler.java:27)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:270)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputs(ReloadableJava17Parser.java:161)
        at org.openrewrite.java.Java17Parser.parseInputs(Java17Parser.java:38)
        at org.springframework.sbm.java.impl.RewriteJavaParser.parseInputs(RewriteJavaParser.java:64)
        at org.springframework.sbm.java.impl.RewriteJavaParser$$FastClassBySpringCGLIB$$93b26c14.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
        at org.springframework.sbm.java.impl.RewriteJavaParser$$EnhancerBySpringCGLIB$$d45f6298.parseInputs(<generated>)
        at org.springframework.sbm.project.parser.MavenProjectParser.parseTestJavaSources(MavenProjectParser.java:210)
        at org.springframework.sbm.project.parser.MavenProjectParser.parse(MavenProjectParser.java:163)
        at org.springframework.sbm.project.parser.ProjectContextInitializer.initProjectContext(ProjectContextInitializer.java:52)
        at org.springframework.sbm.engine.commands.ScanCommand.execute(ScanCommand.java:70)
        at org.springframework.sbm.SpringBootMigratorRunner.run(SpringBootMigratorRunner.java:48)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
        ... 13 more
Caused by: org.openrewrite.java.JavaParsingException: Failed symbol entering or attribution
        ... 34 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null
        at com.sun.tools.javac.comp.TypeEnter.ensureImportsChecked(TypeEnter.java:172)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:627)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:587)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.enterAll(ReloadableJava17Parser.java:338)
        at org.openrewrite.java.isolated.ReloadableJava17Parser.parseInputsToCompilerAst(ReloadableJava17Parser.java:257)
        ... 33 more