I have project (web service) to maintain in Java. Developers who build that project told me that they have used Java 11 and Gradle. So I have installed:
- OpenJDK Server VM Corretto-11.0.11.9.1 (build 11.0.11+9-LTS, mixed mode, emulated-client)
- Gradle 7.0.2
- Eclipse IDE 2021-06 (4.20.0)
on Windows 10.
After configurateing proxy server in Eclipse and downloading all updates result was same as before update, 10785 errors, some of them are:
ActiveProfiles cannot be resolved to a type
ActiveProfilesResolver cannot be resolved to a type
After cannot be resolved to a type
ApplicationPidFileWriter cannot be resolved to a type
Autowired cannot be resolved to a type
Then I installed Spring Tool Suite 4 4.11.0.RELEASE and got same set of errors.
I had more luck with IntelliJ IDEA 2021.1.2 (Community Edition) Build #IC-211.7442.40.
I managed to build project and jar file then I copied jar file on test server (CentOS Linux release 7.5.1804 with OpenJDK 64-Bit Server VM AdoptOpenJDK build 11.0.7+10, mixed mode) run jar file and result was error:
08:39:14.532 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/opt/rim/rim-server-1.0.jar!/com/rim/server/ex/TestingException.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: URL [jar:file:/opt/rim/rim-server-1.0.jar!/com/rim/server/ex/TestingException.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 59
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:454)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275)
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:287)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at com.<omited_private_data>.server.RimServerRoot.runSpring(RimServerRoot.java:28)
at com.<omited_private_data>.server.RimServerRoot.main(RimServerRoot.java:22)
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: URL [jar:file:/opt/rim/rim-server-1.0.jar!/com/rim/server/ex/TestingException.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 59
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:57)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
... 18 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 59
at org.springframework.asm.ClassReader.<init>(ClassReader.java:184)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:166)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:152)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:273)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:54)
... 21 common frames omitted
I have even tried with Apache NetBeans IDE 12.0 result of building project in NetBeans is:
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :assemble UP-TO-DATE
> Task :build
> Task :common:rina-commons:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':common:rina-commons:compileJava'.
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
2
Answers
I have opened project in IntelliJ IDEA clicked on Gradle sidebar:
Right click on build; Chose "Modify run configuration..." On configuration tab in Argument field enter
-x test
; Click OK. Double click on build which will generate jar file.The java version on which your Server is running should be the same version your jar is build with. Your error message "Unsupported class file major version 59" does indikate this for me usually. There are a lot of Threads concerning this:
java.lang.IllegalArgumentException: Unsupported class file major version 59
android launch issues. Unsupported class file major version 57
…