Hi all, I’m trying to upgrade my Grails 6.2.3 app ...
# questions
i
Hi all, I’m trying to upgrade my Grails 6.2.3 app to Grails 7, and I generated a brand-new Grails 7 project from Grails Forge. I picked • Grails 7.0.0-RC1 • Gorm MongoDB • Spring Boot Starter Tomcat • a few additional features (Gradle buildSrc, Grails web console, ect) to make it similar to my app Then in IntelliJ IDEA 2025.2 (latest version of IDE and plugins) I made sure to use JDK 17 (aarch64 distribution, as I’m on Apple silicon). My
build.gradle
is this
Copy code
plugins {
    id "war"
    id "idea"
    id "eclipse"
}

// Not Published to Gradle Plugin Portal
apply plugin: "org.apache.grails.gradle.grails-web"
apply plugin: "org.apache.grails.gradle.grails-gsp"
apply plugin: "org.apache.grails.gradle.grails-gson"

group = "grails7"

repositories {
    mavenCentral()
    maven {
       url = '<https://repo.grails.org/grails/restricted>'
    }
}

dependencies {
    profile "org.apache.grails.profiles:web"
    developmentOnly "org.springframework.boot:spring-boot-devtools" // Spring Boot DevTools may cause performance slowdowns or compatibility issues on larger applications
    testAndDevelopmentOnly "org.webjars.npm:bootstrap"
    testAndDevelopmentOnly "org.webjars.npm:bootstrap-icons"
    testAndDevelopmentOnly "org.webjars.npm:jquery"
    implementation platform("org.apache.grails:grails-bom:$grailsVersion")
    [...]
    implementation "org.springframework.boot:spring-boot-starter-validation"
    console "org.apache.grails:grails-console"
    runtimeOnly "org.fusesource.jansi:jansi"
    [...]
    testImplementation "org.testcontainers:testcontainers"
}

compileJava.options.release = 17

tasks.withType(Test) {
    useJUnitPlatform()
}
When IntelliJ syncs the project I get the error
Copy code
A problem occurred evaluating root project 'grails7_grailsforge'.
> Plugin with id 'org.apache.grails.gradle.grails-web' not found.
The same occurs for the other 2
apply plugin:
statements. If I comment them, I get another error
Copy code
> Could not find method profile() for arguments [org.apache.grails.profiles:web] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
and then the same
Could not find method
error occurs for
developmentOnly
,
testAndDevelopmentOnly
and
console
methods. What am I missing here? Thanks in advance for any advice!
j
you either need a buildScript at the top of your file or a buildSrc/build.gradle that contains the grails-gradle-plugins dependency
@James Fredley did we break forge on this again?
i
My bad, I forgot I replaced the
dependencies
block in
buildSrc/build.gradle
with the one from my Grails 6 app. Sorry about that! The content of the file as downloaded from Grails Forge is this
Copy code
// load the root gradle.properties only for properties not already set
// (e.g., buildSrc/gradle.properties or by environment variables like ORG_GRADLE_PROJECT_grailsVersion=7.0.0)
// <https://github.com/gradle/gradle/issues/2534>
def props = new Properties()
file('../gradle.properties').withInputStream { props.load(it) }
props.each { key, val ->
    if (!project.hasProperty(key)) {
        project.ext."$key" = val
    }
}

repositories {
    mavenCentral()
    maven {
       url = '<https://repo.grails.org/grails/restricted>'
    }
}

dependencies {
    implementation platform("org.apache.grails:grails-bom:$grailsVersion")
    implementation "org.apache.grails:grails-gradle-plugins"
}
But now when IntelliJ syncs the project I get another error:
Copy code
Could not resolve all artifacts for configuration ':buildSrc:buildScriptClasspath'.
> Could not resolve org.apache.grails:grails-gradle-plugins.
  Required by:
      project :buildSrc
   > Dependency requires at least JVM runtime version 17. This build uses a Java 11 JVM.
As I wrote before, I’m sure I configured the project SDK to version 17.
j
that's the jdk setting of gradle itself - you make that change in intellij
hit the settings icon on the gradle view to change it quickly
i
Thank you @jdaugherty!! I naively thought that IntelliJ’s project settings applied to all components of the build process.
However (not an issue in my case as I’m not using
grails-layout
dependency) when I execute
bootRun
task i get this runtime error:
Copy code
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jspViewResolver': Cannot resolve reference to bean 'groovyPagesTemplateEngine' while setting bean property 'templateEngine'
After commenting the dependency the app starts up correctly
This is the stack of exceptions
Copy code
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jspViewResolver': Cannot resolve reference to bean 'groovyPagesTemplateEngine' while setting bean property 'templateEngine'

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Cannot resolve reference to bean 'gspTagLibraryLookup' while setting bean property 'tagLibraryLookup'

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Error creating bean with name 'org.grails.plugins.web.taglib.RenderGrailsLayoutTagLib': Failed properties: Property 'grailsApplication' threw exception: java.lang.NoSuchFieldError: CONFIG_PROPERTY_GSP_GRAILS_LAYOUT_PREPROCESS

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.plugins.web.taglib.RenderGrailsLayoutTagLib': Failed properties: Property 'grailsApplication' threw exception: java.lang.NoSuchFieldError: CONFIG_PROPERTY_GSP_GRAILS_LAYOUT_PREPROCESS

Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'grailsApplication' threw exception: java.lang.NoSuchFieldError: CONFIG_PROPERTY_GSP_GRAILS_LAYOUT_PREPROCESS
j
j
i would strongly urge you to use layout instead of sitemesh3
sitemesh3 has a lot of known issues
when using gsp either the sitemesh3 library or the grails-layout library must be defined
i
Thank you @James Fredley and @jdaugherty! After a few days I managed to get back to the upgrade to Grails 7. In my “clean” Grails 7 app downloaded from Forge, when I try to run
./gradlew build
I get the following error:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all artifacts for configuration ':buildSrc:buildScriptClasspath'.
> Could not resolve org.apache.grails:grails-gradle-plugins.
  Required by:
      project :buildSrc
   > Dependency requires at least JVM runtime version 17. This build uses a Java 11 JVM.
> There is 1 more failure with an identical cause.
The content from
buildSrc/build.gradle
is the same as shown a few messages above. Again, in IntelliJ IDEA I made sure both the project SDK and Gradle JVM are set to 17. I’m sorry, I’m still trying to wrap my head around the project config 😓 Thanks for your patience
j
You will need to use 7.0.0-SNAPSHOT on start.grails.org, it has the fix for the buildSrc bug.
It will also be in 7.0.0-RC2 in coming weeks.
Or skip the Gradle buildSrc feature on 7.0.0-RC1, if you do not have any custom code in buildSrc for your project.
i
Got it, thank you so much for your help! 🙏🏻
❤️ 1