Jon V.
Jon V.

Reputation: 1

*unable to resolve class" issue when upgrading from grails 2.5.4 to grails 3.3.11

I inherited a multi-module grails application based on Grails 2.5.4.

It's working nice and well, but I need to upgrade to 3.x.

I installed groovy 3.0.4 and grails 3.3.11, and I completed the grails upgrade tasks base on the tutorial provided on the official website (https://docs.grails.org/3.0.x/guide/upgrading.html).

As I try to build the project, I'm facing multiple *unable to resolve class" issues related to bases classes such as:

Starting a Gradle Daemon (subsequent builds will be faster)
:compileAstJava NO-SOURCE
:compileAstGroovy NO-SOURCE
:processAstResources NO-SOURCE
:astClasses UP-TO-DATE
:compileJava NO-SOURCE
:configScript
:compileGroovy
startup failed:
C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\holders\Exclusion.groovy: 5: unable to     resolve class org.grails.databinding.BindingFormat
 @ line 5, column 1.
   import org.grails.databinding.BindingFormat
   ^

C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\migration\CustomsLgcy.groovy: 5: unable to resolve class org.postgresql.core.Query
 @ line 5, column 1.
   import org.postgresql.core.Query
   ^

C:\repo\upgraded-app\myapp-core\grails-app\services\bittt\ExclusionService.groovy: 13: unable to resolve class org.grails.web.servlet.mvc.GrailsParameterMap
 @ line 13, column 1.
   import org.grails.web.servlet.mvc.GrailsParameterMap
   ^

C:\repo\upgraded-app\myapp-core\grails-app\services\bittt\NotificationService.groovy: 12: unable to resolve class org.grails.commons.GrailsApplication
 @ line 12, column 1.
   import org.grails.commons.GrailsApplication
   ^
...

My myapp.core build.gradle file contains the following:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
    }
}

version "0.1"
group "myapp.core"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.16.Final"
    compile "org.grails.plugins:gsp"

    compile 'org.grails.plugins:spring-security-core:3.2.3'
    compile 'org.grails.plugins:spring-security-acl:3.2.1'
    compile "org.grails.plugins:phonenumbers:0.10"

    console "org.grails:grails-console"
    profile "org.grails.profiles:web-plugin"
    provided "org.grails:grails-plugin-services"
    provided "org.grails:grails-plugin-domain-class"
    
    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "com.h2database:h2"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-web-testing-support"
    testCompile "org.grails.plugins:geb:1.1.2"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
    testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:2.47.1"
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
    systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}

assets {
    minifyJs = true
    minifyCss = true
}

I don't really understand why I'm getting those errors as the relevant dependencies seem to be in place... anything I'm missing here ?

Thanks :)

Upvotes: 0

Views: 1304

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27255

C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\holders\Exclusion.groovy: 5: unable to resolve class org.grails.databinding.BindingFormat @ line 5, column 1. import org.grails.databinding.BindingFormat

In Grails 3.3.11, the package is grails.databinding, not org.grails.databinding (https://github.com/grails/grails-core/blob/v3.3.11/grails-databinding/src/main/groovy/grails/databinding/BindingFormat.java). The package names also changed for org.grails.web.servlet.mvc.GrailsParameterMap (https://github.com/grails/grails-core/blob/v3.3.11/grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java) and import org.grails.commons.GrailsApplication (https://github.com/grails/grails-core/blob/v3.3.11/grails-core/src/main/groovy/grails/core/GrailsApplication.java).

org.postgresql.core.Query is a separate problem. It looks like your project does not express a dependency on the postgres library, so the class isn't available to the app.

Upvotes: 1

Related Questions