Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load classpath resources for sqlFile changesets #169

Open
acanby opened this issue Mar 31, 2020 · 1 comment · May be fixed by #171 or #170
Open

Unable to load classpath resources for sqlFile changesets #169

acanby opened this issue Mar 31, 2020 · 1 comment · May be fixed by #171 or #170

Comments

@acanby
Copy link

acanby commented Mar 31, 2020

I'm trying to integrate Spring Batch into my Grails application. The Spring Batch jar supplies per dbms schemas for the required tables, and I have been trying to add this via dbm/liquibase. It seems like something that liquibase supports, and I have seen examples for vanilla Spring Boot/Liquibase that seem to work.

I have a changelog as follows:

databaseChangeLog = {
    changeSet(author: "user", id: "spring-batch-schema-4.2.1.RELEASE", dbms: 'mssql') {
        sqlFile(encoding: "utf8",
                splitStatements: true,
                stripComments: true,
                relativeToChangelogFile: false,
                path: 'classpath:/org/springframework/batch/core/schema-sqlserver.sql'
        )
    }
}

This seems like it should work - but I get the below exception:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-31 13:05:50.125 ERROR --- [  restartedMain] <> o.s.boot.SpringApplication               : Application run failed

liquibase.exception.UnexpectedLiquibaseException: java.io.IOException: File does not exist: 'classpath:/org/springframework/batch/core/schema-sqlserver.sql'
        at liquibase.change.AbstractSQLChange.generateCheckSum(AbstractSQLChange.java:189)
        at liquibase.changelog.ChangeSet.generateCheckSum(ChangeSet.java:255)
        at liquibase.changelog.ChangeSet.toString(ChangeSet.java:807)
        at liquibase.changelog.ChangeLogIterator.createKey(ChangeLogIterator.java:105)
        at liquibase.changelog.ChangeLogIterator.alreadySaw(ChangeLogIterator.java:113)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:77)
        at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:269)
        at liquibase.Liquibase.update(Liquibase.java:198)
        at liquibase.Liquibase.update(Liquibase.java:179)
        at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:317)
        at org.grails.plugins.databasemigration.liquibase.GrailsLiquibase.performUpdate(GrailsLiquibase.groovy:83)

So I did some digging into the exception. A change was added in 7e46268#diff-9735b2073ff7adabaa25c8f0085a81f2 that overrode the createLiquibase method from the default SpringLiquibase one. It changes the resourceAccessor to the parent of the one used by SpringLiquibase (i.e. removing all Spring awareness).

I'd like to propose changing the resourceAccessor back to the Spring one. I've made the code changes: b5ca952. Using this code I can now load the file from the Spring Batch Jar.

If this change was made for a specific reason, I can understand the hesitation to change the implementation for everyone. I'd like to have the option of creating my own GrailsLiquibase instances, but the plugin specifically uses new. Perhaps this could be exposed via a bean factory? Code here: acanby@3a1e051.

@andrewcanby-finocomp
Copy link

Any thoughts on this one @puneetbehl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants