Laxmi Salunkhe
Laxmi Salunkhe

Reputation: 509

Class Not Found errors when upgrading grails to 2.5.0 for Grails database migrations files

I am trying to upgrade Grails app from 2.4.3 to 2.5.0 version. Grails 2.5.0 contains fixes and improvements but doesn't have any breaking changes. Also, installed all 2.5.0 compatible plugin versions.

Also gone through Grails Database Migration Plugin changelog and other plugin to support grails 2.5.0. Come across same JIRA Issue I am facing right now - Jira Link , but it's already fixed in old Grails database migration plugin release.

BuildConfig.groovy

grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.reload.enabled = true
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
    inherits("global") {
    }
    log "warn"
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()
        mavenRepo "http://repo.grails.org/grails/core" // Dependency for export plugin.
    }
    dependencies {
        compile ("org.apache.jclouds.provider:cloudfiles-us:1.6.2-incubating", "org.jclouds:jclouds-compute:1.6.0") {
            excludes "jclouds-core"
        }
        compile 'commons-beanutils:commons-beanutils:1.8.3'
        compile "org.apache.jclouds:jclouds-core:1.7.2"
        runtime 'mysql:mysql-connector-java:5.1.29'
    }

    plugins {
        runtime ':database-migration:1.4.0'
        runtime ":hibernate:3.6.10.18"
        runtime ":jquery:1.11.0.2"
        runtime ":resources:1.2.14"
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        build ":tomcat:7.0.55.2"
    }
}

StackTrace I have migration file named upgrade-2.1.groovy at default migrations location grails-app/migrations

| Error 2015-04-30 10:52:09,868 [localhost-startStop-1] ERROR 
    context.GrailsContextLoaderListener  - Error initializing the 
    application: Error creating bean with name 'grailsApplication' 
    defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1
Message: Error creating bean with name 'grailsApplication' defined 
    in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1

    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by GrailsConfigurationException: Class not found loading Grails application: upgrade-2.1
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by ClassNotFoundException: upgrade-2.1
->>  366 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run       in     ''
|    354 | findClass in java.net.URLClassLoader
|    425 | loadClass in java.lang.ClassLoader
|    262 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Upvotes: 4

Views: 882

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75681

This isn't related to the plugin or Grails - the problem is that upgrade-2.1 isn't a valid name for a Groovy script. You can only use names that would be valid class names. You'll have to replace the period with another character and also possibly the dash. Try upgrade_2_1.groovy.

Upvotes: 6

Related Questions