Skip to content

Cannot invoke "org.openrewrite.java.tree.JavaType$FullyQualified.getFullyQualifiedName() #589

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

Closed
vladmihalcea opened this issue Dec 9, 2022 · 10 comments · Fixed by #773
Closed
Assignees
Labels
in: sbm-core type: bug Something isn't working

Comments

@vladmihalcea
Copy link

Describe the bug
A clear and concise description of what the bug is.

When running a scan, I get this error:

09:37:53.297 [main] ERROR o.s.s.j.impl.ProjectJavaSourcesImpl - Could not calculate if class 'org.openrewrite.java.tree.J$ClassDeclaration@ec63dc0a' implements an interface compatible to 'org.springframework.data.jpa.repository.JpaRepository'. Type of interface 'Filter' could not be resolved and was 'Unknown'
09:37:53.306 [main] ERROR o.s.s.j.impl.ProjectJavaSourcesImpl -
java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.JavaType$FullyQualified.getFullyQualifiedName()" because "fullyQualified" is null
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.lambda$hasTypeImplementing$12(ProjectJavaSourcesImpl.java:159)
        at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
        at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)

Desktop (please complete the following information):

  • Windows
  • Version: 0.13.0

Additional context

The same issue happens when running a recipe:

Applying recipe 'sbu30-report'
Action [SpringBootUpgradeReportAction] 'Creates a Upgrade report for Spring Boot 3.' failed: Cannot invoke "org.openrewrite.java.tree.JavaType$FullyQualified.getFullyQualifiedName()" because the return value of "org.openrewrite.java.tree.TypeUtils.asFullyQualified(org.openrewrite.java.tree.JavaType)" is null
Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace.
@fabapp2
Copy link
Contributor

fabapp2 commented Dec 15, 2022

Hi @vladmihalcea !

Thanks for giving SBM a try and reporting this issue 🚀

The error message indicates that the type for Filter could not be resolved.
This is the case if the source was not scanned, e.g. because it's under target/generated-sources (see #590) or for some other reason not part of the AST.

I wrote a test for a single module and types from JDK (Serailizable) interface as well as ApplicationContextAware from spring-context could be resolved. So I assume it's something else that made it fail on your side.

Could you provide information about the Filter interface that was not found and the application?

Looking at the message You can use the stacktrace command to print the full stacktrace. makes me think you've been using the sbm-shell (spring-boot-migrator.jar) which is ok and should work too.
But spring-boot-upgrade.jar will (hopefully) be easier and better to use. I doubt that it would solve this issue though.

@fabapp2 fabapp2 added type: bug Something isn't working in: sbm-core labels Dec 15, 2022
@vladmihalcea
Copy link
Author

@fabapp2 I tried the tool against this public repository and got that error.

You can try it too and see if you can replicate it.

@fabapp2
Copy link
Contributor

fabapp2 commented Dec 15, 2022

Hi @vladmihalcea
I can't reproduce. Neither with main nor with the two 0.13.0 jars from releases running against 3e4765d2dc2522ab2b0dda0f3ad16cd3c55e7eab.
It scans and produces the report as expected in both applications (migrator and upgrade).
I need to run now but will try once more with a clean .m2/repository and under Windows too.
These are the only things I could think (right now) that might be causing the issue (actually I doubt that Windows is the problem).
I guess you used the recent 0.13.0 version?

@vladmihalcea
Copy link
Author

@fabapp2 Then it could be a Windows issue. I tested the 0.13.0 version of the tool that was available on GitHub.

@fabapp2
Copy link
Contributor

fabapp2 commented Dec 16, 2022

@vladmihalcea I tried under Windows and the report was created with both 0.13.0 jars, so I can't reproduce the error.
The only thing that I can think of right now is a broken jar
Could you do me a favour and try again with a clean .m2/repository dir and cleaned ~/.rewrite/cache/artifacts to see if a broken jar was causing the issue?

@vladmihalcea
Copy link
Author

vladmihalcea commented Dec 16, 2022

I re-downloaded the 0.13.0 version from GitHub.

I rebuilt the project and ran the scan on it, and this is the output:

migrator:> scan d:/Vlad/Work/GitHub/spring-account-transfer

scanning 'd:/Vlad/Work/GitHub/spring-account-transfer'

Checked preconditions for 'D:\Vlad\Work\GitHub\spring-account-transfer'
[ok] Found pom.xml.
[ok] 'sbm.gitSupportEnabled' is 'true', changes will be committed to branch [spring-6] after each recipe.
[ok] Required Java version (17) was found.
[ok] Found required source dir 'src/main/java'.


Maven        100% │██████████████████████████████████│ 2/2 (0:00:09 / 0:00:00)
17:25:54.729 [main] ERROR o.s.s.j.impl.ProjectJavaSourcesImpl - Could not calculate if class 'org.openrewrite.java.tree.J$ClassDeclaration@442de621' implements an interface compatible to 'org.springframework.data.jpa.repository.JpaRepository'. Type of interface 'Filter' could not be resolved and was 'Unknown'
17:25:54.736 [main] ERROR o.s.s.j.impl.ProjectJavaSourcesImpl -
java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.JavaType$FullyQualified.getFullyQualifiedName()" because "fullyQualified" is null
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.lambda$hasTypeImplementing$12(ProjectJavaSourcesImpl.java:159)
        at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
        at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
        at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:632)
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.hasTypeImplementing(ProjectJavaSourcesImpl.java:150)
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.lambda$findTypesImplementing$6(ProjectJavaSourcesImpl.java:123)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.lambda$findTypesImplementing$8(ProjectJavaSourcesImpl.java:128)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.springframework.sbm.java.impl.ProjectJavaSourcesImpl.findTypesImplementing(ProjectJavaSourcesImpl.java:121)
        at org.springframework.sbm.boot.upgrade_24_25.filter.SpringDataJpaAnalyzer.getJpaRepositoriesWithGetByIdMethod(SpringDataJpaAnalyzer.java:36)
        at org.springframework.sbm.boot.upgrade_24_25.conditions.Boot_24_25_SpringDataJpaActionCondition.evaluateAgainstModule(Boot_24_25_SpringDataJpaActionCondition.java:42)
        at org.springframework.sbm.boot.upgrade_24_25.conditions.Boot_24_25_SpringDataJpaActionCondition.evaluate(Boot_24_25_SpringDataJpaActionCondition.java:36)
        at org.springframework.sbm.engine.recipe.Recipe.isApplicable(Recipe.java:92)
        at org.springframework.sbm.engine.recipe.Recipes.lambda$getApplicable$2(Recipes.java:50)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at org.springframework.sbm.engine.recipe.Recipes.getApplicable(Recipes.java:51)
        at org.springframework.sbm.engine.commands.ApplicableRecipeListCommand.getApplicableRecipes(ApplicableRecipeListCommand.java:56)
        at org.springframework.sbm.engine.commands.ApplicableRecipeListCommand.execute(ApplicableRecipeListCommand.java:60)
        at org.springframework.sbm.shell.ScanShellCommand.scan(ScanShellCommand.java:72)
        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:158)
        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)

The same issue.

@nameof
Copy link

nameof commented Mar 14, 2023

This is fixed now #750

@sanagaraj-pivotal
Copy link
Contributor

picking this up

@sanagaraj-pivotal
Copy link
Contributor

sanagaraj-pivotal commented Apr 26, 2023

@vladmihalcea
We think the issue is because of corrupted jars in local maven repository or in rewrite maven artifact cache.

please delete ~/.m2/repository and ~/.rewrite/cache/artifacts

we can confirm that this issue is not related to windows operating system because we were successfully unit test the scenario that you were having.

P.S.
We are moving away from command line SBM tool for the purposes of Spring migration, please use Spring boot upgrade web ui tool instead.

@fabapp2
Copy link
Contributor

fabapp2 commented Apr 26, 2023

Created #774 to solve the next problem when upgrading the given demo application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: sbm-core type: bug Something isn't working
Projects
None yet
4 participants