grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

JDK 17 Support / Gradle 7.3.0

Open codeconsole opened this issue 4 years ago • 11 comments
trafficstars

Gradle 7.3.0 will soon be released (Currently RC3) and will support JDK 17

JDK is the new LTS and was released in September.

JDK 17 requires asm 9.1 and Groovy 3.0.8 is the first version to support it.

Fortunately, Grails 5.0.0 introduced groovyVersion in gradle.properties and can be updated to Groovy 3.0.8+, so now is the time to start planning for JDK 17 support once Gradle 7.3.0 is released.

Current Gradle Computability Matrix

codeconsole avatar Oct 25 '21 16:10 codeconsole

Grails 5.0.0 depends on Groovy 3.0.7, not 3.0.8.

It would be great to wait for Groovy 3.0.10 when it is released. We have runtime issues with Groovy 3.0.8 and 3.0.9..

Taack avatar Oct 26 '21 06:10 Taack

For us Grails 5.0.0 works with Gradle 7.2 and JDK 17 (I believe we have some lucky combination of plugins, which doesn't cause issues). We use gradle resolutionStrategy to force groovy 3.0.9 in our app, though.

But release of 5.0.1 with gradle 7.3 and groovy 3.0.9 out of the box would be highly appreciated.

arixmkii avatar Oct 26 '21 07:10 arixmkii

@Taack yeah, I realized I had already updated the groovy version prior to 5.0.0 being released. I am getting runtime issues as well with my production app. Are you experiencing something similar and do you expect it to be resolved with Groovy 3.0.10?

I have successfully run and built an app using Gradle 7.3 rc2 / Groovy 3.0.8, but in my main production app i have an issue just running my main app with JDK 17 even if it is built with JDK 11. Running the same jar with JDK 11 works find.

Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is groovy.lang.MissingMethodException: No signature of method: java.lang.Object.clone() is applicable for argument types: () values: []
Possible solutions: collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure), find(), any(), any(groovy.lang.Closure)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:389)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:134)

codeconsole avatar Oct 26 '21 14:10 codeconsole

I diagnosed my issue and found it is do to having multiple dataSources configured in application.yml

Example App

I have created the following issue that needs to be resolved in order to support JDK 17 https://github.com/grails/gorm-hibernate5/issues/402

codeconsole avatar Oct 26 '21 18:10 codeconsole

@codeconsole I reported one issue GROOVY-10320, it will be resolved with Groovy 3.0.10. I do have another one against Groovy 3.0.8 which cause me headheck, but has been resolved with Groovy 3.0.9 (so I do not report the later).

Taack avatar Oct 27 '21 07:10 Taack

This will probably depend on Groovy 4.x support https://github.com/grails/grails-core/issues/12373

codeconsole avatar Feb 05 '22 17:02 codeconsole

I can confirm Grails 5.1.7 working with JDK 17 using Groovy 3.0.11-SNAPSHOT I had to use gradle bootRun

However, the grails cli does not work.

% grails
| Error Failed to compile CreateFunctionalTest.groovy: startup failed:
General error during conversion: Unsupported class file major version 61

java.lang.IllegalArgumentException: Unsupported class file major version 61
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:189)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:170)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:156)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:277)
	at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
	at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:251)
	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:189)
	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:169)
	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:125)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClassNullable(AsmReferenceResolver.java:57)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:44)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveNonArrayType(AsmReferenceResolver.java:79)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveType(AsmReferenceResolver.java:70)
	at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.createMethodNode(MemberSignatureParser.java:49)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lambda$createMethodNode$1(DecompiledClassNode.java:230)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.createMethodNode(DecompiledClassNode.java:236)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitMembers(DecompiledClassNode.java:203)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getDeclaredMethods(DecompiledClassNode.java:122)
	at org.codehaus.groovy.ast.ClassNode.tryFindPossibleMethod(ClassNode.java:1283)
	at org.codehaus.groovy.control.StaticImportVisitor.transformMethodCallExpression(StaticImportVisitor.java:251)
	at org.codehaus.groovy.control.StaticImportVisitor.transform(StaticImportVisitor.java:133)
	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:108)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
	at org.codehaus.groovy.control.StaticImportVisitor.visitConstructorOrMethod(StaticImportVisitor.java:108)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:101)
	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1089)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
	at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:209)
	at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
	at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
	at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:288)
	at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.readCommandFile(GroovyScriptCommandFactory.groovy:50)
	at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.readCommandFile(GroovyScriptCommandFactory.groovy)
	at org.grails.cli.profile.commands.factory.ResourceResolvingCommandFactory.findCommands(ResourceResolvingCommandFactory.groovy:44)
	at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy:86)
	at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy)
	at org.grails.cli.profile.AbstractProfile.getCommands(AbstractProfile.groovy:432)
	at org.grails.cli.profile.repository.AbstractJarProfileRepository$JarProfile.getCommands(AbstractJarProfileRepository.groovy:130)
	at org.grails.cli.profile.AbstractProfile.getCompleters(AbstractProfile.groovy:362)
	at org.grails.cli.GrailsCli.setupCompleters(GrailsCli.groovy:420)
	at org.grails.cli.GrailsCli.handleInteractiveMode(GrailsCli.groovy:402)
	at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:273)
	at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)

1 error
 (Use --stacktrace to see the full trace)
| Error Error occurred running Grails CLI: Cannot invoke "org.grails.cli.profile.commands.script.GroovyScriptCommand.setProfile(org.grails.cli.profile.Profile)" because "data" is null (Use --stacktrace to see the full trace)

codeconsole avatar Apr 14 '22 23:04 codeconsole

The only JDK 17 issues that seem to be remaining are grails cli issues.

% grails -v
| Grails Version: 5.1.8
| JVM Version: 17.0.3
% grails create-app grails4bugs
| Application created at /grails4bugs
% cd grails4bugs
| Resolving Dependencies. Please wait...

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

CONFIGURE SUCCESSFUL in 4s
| Error Failed to compile CreateFunctionalTest.groovy: startup failed:
General error during conversion: Unsupported class file major version 61

java.lang.IllegalArgumentException: Unsupported class file major version 61
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:189)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:170)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:156)

codeconsole avatar Jun 09 '22 21:06 codeconsole

FYI JDK 17 is version 61 so the CLI is not supporting compiling itself

codeconsole avatar Jun 10 '22 14:06 codeconsole

This seems like an issue being enforced by the framework

https://github.com/grails/grails-spring-security-core/issues/767 https://github.com/grails-plugins/grails-spring-security-ui/issues/127 https://github.com/grails/grails-spring-security-core/issues/737

codeconsole avatar Jun 10 '22 14:06 codeconsole

I ran grails 5.2.2 with jdk 17 by ./gradlew bootRun and it worked normally.

fernando88to avatar Aug 03 '22 17:08 fernando88to

I can confirm JDK 17 is now working

codeconsole avatar Oct 15 '22 16:10 codeconsole

Hello, can we announce official support for java 17? Now documentation says: "We have tested most Grails projects up to JDK 14." https://docs.grails.org/5.2.x/guide/single.html#whatsNew

agre1981 avatar Jan 20 '23 12:01 agre1981

Has the fix for JDK17 been released into the latest Grails 5.2.5 release?

When using Grails 5.2.5 with JDK17, I am unable to build. It did not help changing the Gradle Wrapper from 7.2 to 7.3, or 7.6

./gradlew bootRun and grails run-app Works fine, but ./gradlew build fails like this.

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':configureChromeDriverBinary'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:142)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
Caused by: java.lang.IllegalAccessException: module jdk.proxy4 does not open jdk.proxy4 to unnamed module @32464a14
        ... 134 more

This comes from a project created with grails create-app helloworld.

DJViking avatar Feb 01 '23 10:02 DJViking

Yes, you are right, build doesn't work in 5.2.5, at least for me )

Looks this relates to the issue: https://github.com/erdi/webdriver-binaries-gradle-plugin/issues/30

Caused by: java.lang.IllegalAccessException: module jdk.proxy4 does not open jdk.proxy4 to unnamed module @20e2cbe0
	... 139 more

agre1981 avatar Feb 03 '23 10:02 agre1981

Adding this to dependencies fixes the issue

buildscript {
    dependencies {
        classpath "org.ysb33r.gradle:grolifant50:2.0.0-alpha.6"    
    }

agre1981 avatar Feb 03 '23 11:02 agre1981