Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 3 database-migration-plugin initialization error

I recently added database-migration-plugin to my grails 3.0.11 app. The problem is when I try to run-app I get a following error:

ERROR grails.boot.GrailsApp - Application startup failed
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'springLiquibase_dataSource': 
Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: 
java.lang.IllegalArgumentException: Script text to compile cannot be null!

Looks like it can't find changelog.xml in my grails-app/migrations folder. My build.gradle file contains:

buildscript {
    dependencies {
        classpath "org.grails.plugins:database-migration:2.0.0.RC1"
    }
}

and

sourceSets {
    main {
        resources {
            srcDir 'grails-app/migrations'
        }
    }
}

I also added the following lines in my application.groovy file:

grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']

I would by very gratefull for any advice how to make database-migration-plugin work properly.

Edit:

I created changelog.xml file using $grails dbm-create-changelog command

I also added to build.gradle (as suggested by $grails plugin-info database-migration command):

dependencies {
    compile "org.grails.plugins:database-migration:2.0.0.RC1"
}

then I changed it to (following official documentation):

dependencies {
    runtime "org.grails.plugins:database-migration:2.0.0.RC1"
}

and then (as suggested by manual for startup error) I forced liquibase:

dependencies {
    compile 'org.liquibase:liquibase-core:3.3.2'
    runtime 'org.grails.plugins:database-migration:2.0.0.RC1'
}

and

dependencies {
    compile 'org.liquibase:liquibase-core:3.3.2'
    compile 'org.grails.plugins:database-migration:2.0.0.RC1'
}

The problem still remains: java.lang.IllegalArgumentException: Script text to compile cannot be null!

like image 682
iTiger Avatar asked Feb 01 '16 14:02

iTiger


1 Answers

We ran into the same problem when upgrading to Grails 3.

A look into the code of the grails-database-migration plugin made clear that the configuration parameter is changed from a list updateOnStartFileNames to a single value updateOnStartFileName.

So when you change your config from

grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']

to

grails.plugin.databasemigration.updateOnStartFileName = 'changelog.xml'

it should work again.

like image 76
Hans Bogaards Avatar answered Oct 04 '22 21:10

Hans Bogaards