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

SBM fails on startup when using latest version #396

Closed pavankjadda closed 2 years ago

pavankjadda commented 2 years ago

Describe the bug SBM fails when I start with command java -jar spring-boot-migrator.jar

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/spring-projects-experimental/spring-boot-migrator/releases and download latest release
  2. Run java -jar spring-boot-migrator.jar on local machine
  3. See error

Expected behavior SBM should run without any issues

Stacktrace

00:27:14.606 [main] WARN  o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'describeShellCommand' defined in URL [jar:file:/Users/jaddap2/spring-boot-migrator.jar!/BOOT-INF/classes!/org/springframework/sbm/shell/DescribeShellCommand.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'describeCommand' defined in URL [jar:file:/Users/jaddap2/spring-boot-migrator.jar!/BOOT-INF/lib/sbm-core-0.11.0.jar!/org/springframework/sbm/engine/commands/DescribeCommand.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'recipesBuilder': Unsatisfied dependency expressed through field 'beanRecipes'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxRs' defined in class path resource [org/springframework/sbm/jee/jaxrs/MigrateJaxRsRecipe.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
00:27:14.644 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'describeShellCommand' defined in URL [jar:file:/Users/jaddap2/spring-boot-migrator.jar!/BOOT-INF/classes!/org/springframework/sbm/shell/DescribeShellCommand.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'describeCommand' defined in URL [jar:file:/Users/jaddap2/spring-boot-migrator.jar!/BOOT-INF/lib/sbm-core-0.11.0.jar!/org/springframework/sbm/engine/commands/DescribeCommand.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'recipesBuilder': Unsatisfied dependency expressed through field 'beanRecipes'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxRs' defined in class path resource [org/springframework/sbm/jee/jaxrs/MigrateJaxRsRecipe.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:448)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
    at org.springframework.sbm.SpringShellApplication.main(SpringShellApplication.java:27)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    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:88)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'describeCommand' defined in URL [jar:file:/Users/jaddap2/spring-boot-migrator.jar!/BOOT-INF/lib/sbm-core-0.11.0.jar!/org/springframework/sbm/engine/commands/DescribeCommand.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'recipesBuilder': Unsatisfied dependency expressed through field 'beanRecipes'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxRs' defined in class path resource [org/springframework/sbm/jee/jaxrs/MigrateJaxRsRecipe.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'recipesBuilder': Unsatisfied dependency expressed through field 'beanRecipes'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxRs' defined in class path resource [org/springframework/sbm/jee/jaxrs/MigrateJaxRsRecipe.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    ... 38 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxRs' defined in class path resource [org/springframework/sbm/jee/jaxrs/MigrateJaxRsRecipe.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1607)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1460)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1347)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
    ... 53 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.sbm.engine.recipe.Recipe]: Factory method 'jaxRs' threw exception; nested exception is java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    ... 69 common frames omitted
Caused by: java.lang.IllegalAccessError: superclass access check failed: class org.openrewrite.java.Java11Parser$ByteArrayCapableJavacFileManager (in unnamed module @0x3b6eb2ec) cannot access class com.sun.tools.javac.file.JavacFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module @0x3b6eb2ec
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:383)
    at java.base/java.lang.Class.forName(Class.java:376)
    at org.openrewrite.java.JavaParser.fromJavaVersion(JavaParser.java:105)
    at org.springframework.sbm.java.impl.RewriteJavaParser.buildJavaParser(RewriteJavaParser.java:53)
    at org.springframework.sbm.java.impl.RewriteJavaParser.<init>(RewriteJavaParser.java:48)
    at org.springframework.sbm.java.impl.JavaParserFactory.getCurrentJavaParser(JavaParserFactory.java:38)
    at org.springframework.sbm.jee.jaxrs.recipes.ReplaceMediaType.<init>(ReplaceMediaType.java:93)
    at org.springframework.sbm.jee.jaxrs.MigrateJaxRsRecipe.jaxRs(MigrateJaxRsRecipe.java:92)
    at org.springframework.sbm.jee.jaxrs.MigrateJaxRsRecipe$$EnhancerBySpringCGLIB$$86a180af.CGLIB$jaxRs$0(<generated>)
    at org.springframework.sbm.jee.jaxrs.MigrateJaxRsRecipe$$EnhancerBySpringCGLIB$$86a180af$$FastClassBySpringCGLIB$$71fe2fb8.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
    at org.springframework.sbm.jee.jaxrs.MigrateJaxRsRecipe$$EnhancerBySpringCGLIB$$86a180af.jaxRs(<generated>)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)

Desktop (please complete the following information):

Additional context I am using Java 18.0.2

fabapp2 commented 2 years ago

Hi @pavankjadda

Thanks for trying SBM and reporting this. 🚀 You need to use JDK 11 until the upcoming SBM release. Hope it works then, please let us know.

I'll create a new issue to provide an error message instead of this stacktrace.