Issue
Just as a sanity test I tried to compile and then run the default Spring-Boot start application.
I compiled the project into a Jar file with Maven but when I tired to run the application I received the following output:
[@YCApp61 ~/WorkDir]$ java -jar ./MyService-0.0.1-SNAPSHOT.jar com.myCompany.myApp.MyServiceApplication
2022-02-24 20:52:29.627 INFO 81808 --- [ main] com.myCompany.myApp.MyService.App : Starting App v0.0.1-SNAPSHOT with PID 81808 (/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar started by usr in /usr/home/usr/WorkDir)
2022-02-24 20:52:29.704 INFO 81808 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@707302d6: startup date [Thu Feb 24 20:52:29 UTC 2022]; root of context hierarchy
2022-02-24 20:52:30.598 INFO 81808 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2022-02-24 20:52:30.712 INFO 81808 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-web-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-autoconfigure-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-logging-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jcl-over-slf4j-1.7.12.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/slf4j-api-1.7.12.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jul-to-slf4j-1.7.12.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/log4j-over-slf4j-1.7.12.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/logback-classic-1.1.3.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/logback-core-1.1.3.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/snakeyaml-1.14.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-tomcat-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-core-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-el-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-logging-juli-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-embed-websocket-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jackson-databind-2.4.6.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jackson-annotations-2.4.6.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jackson-core-2.4.6.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/hibernate-validator-5.1.3.Final.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/validation-api-1.1.0.Final.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/jboss-logging-3.1.3.GA.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/classmate-1.0.0.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-core-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-web-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-aop-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/aopalliance-1.0.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-beans-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-context-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-webmvc-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-expression-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-boot-starter-jdbc-1.2.7.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-jdbc-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-jdbc-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/tomcat-juli-8.0.28.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/spring-tx-4.1.8.RELEASE.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/h2-1.4.190.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/lombok-1.14.8.jar!/, jar:file:/usr/home/usr/WorkDir/MyService-0.0.1-SNAPSHOT.jar!/lib/log4jdbc-log4j2-jdbc4.1-1.16.jar!/]
2022-02-24 20:52:30.717 ERROR 81808 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Cannot load configuration class: com.myCompany.myApp.MyService.App
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:395)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:259)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:126)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:607)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
at com.myCompany.myApp.MyService.App.main(App.java:9)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError: null
at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:166)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:116)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:108)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:104)
at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:112)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:100)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:385)
... 17 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2c60a1a7
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Method.setAccessible(Unknown Source)
at org.springframework.cglib.core.ReflectUtils$2.run(ReflectUtils.java:56)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:46)
... 28 common frames omitted
2022-02-24 20:52:30.718 INFO 81808 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@707302d6: startup date [Thu Feb 24 20:52:29 UTC 2022]; root of context hierarchy
2022-02-24 20:52:30.720 WARN 81808 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@707302d6: startup date [Thu Feb 24 20:52:29 UTC 2022]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:873)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:150)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:840)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
at com.myCompany.myApp.MyService.App.main(App.java:9)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.base/java.lang.Thread.run(Unknown Source)
2022-02-24 20:52:30.720 WARN 81808 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@707302d6: startup date [Thu Feb 24 20:52:29 UTC 2022]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:357)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:881)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:150)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:840)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
at com.myCompany.myApp.MyService.App.main(App.java:9)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.base/java.lang.Thread.run(Unknown Source)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Cannot load configuration class: com.myCompany.myApp.MyService.App
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:395)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:259)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:126)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:607)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
at com.myCompany.myApp.MyService.App.main(App.java:9)
... 6 more
Caused by: java.lang.ExceptionInInitializerError
at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:166)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:116)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:108)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:104)
at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:112)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:100)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:385)
... 17 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2c60a1a7
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Method.setAccessible(Unknown Source)
at org.springframework.cglib.core.ReflectUtils$2.run(ReflectUtils.java:56)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:46)
... 28 more
[usr@YCApp61 ~/WorkDir]$
I tried running the application again with the following arguments but got the same error message:
java -jar ./MyService-0.0.1-SNAPSHOT.jar com.myCompany.myApp.MyServiceApplication --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED
The machine I am trying to run on is Java 17. Am I missing some jvm arguments or am I passing them incorrectly?
Solution
Chin Huang was correct above, changing to project to use version 2.6.3 of spring-boot fixed the issue.
Answered By - RichardFeynman
Answer Checked By - Terry (JavaFixing Volunteer)