liquibase: executeCommand changeSet fails on >=3.10.1
Environment
Liquibase Version: >=3.10.1
Liquibase Integration & Version: ant
Liquibase Extension(s) & Version:
Database Vendor & Version: MariaDB 10.3
Operating System Type & Version: Debian Stretch
Description
A changeSet with only a <executeCommand>
statement fails in >=3.10.1, it works under 3.10.0.
Unable to update database. liquibase.exception.MigrationFailedException: Migration failed for change set liquibase.xml::xxxx::xxxx:
Reason: java.lang.ClassCastException: liquibase.database.jvm.JdbcConnection cannot be cast to com.datical.liquibase.ext.database.jvm.ProJdbcConnection
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:659)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:97)
at liquibase.Liquibase.update(Liquibase.java:201)
at liquibase.Liquibase.update(Liquibase.java:178)
at liquibase.Liquibase.update(Liquibase.java:328)
at liquibase.integration.ant.DatabaseUpdateTask.executeWithLiquibaseClassloader(DatabaseUpdateTask.java:34)
at liquibase.integration.ant.BaseLiquibaseTask.execute(BaseLiquibaseTask.java:88)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: java.lang.ClassCastException: liquibase.database.jvm.JdbcConnection cannot be cast to com.datical.liquibase.ext.database.jvm.ProJdbcConnection
at com.datical.liquibase.ext.SqlPlusRunner.buildConnectionString(Unknown Source)
at com.datical.liquibase.ext.SqlPlusRunner.createFinalCommandArray(Unknown Source)
at liquibase.change.core.ExecuteShellCommandChange.generateStatements(ExecuteShellCommandChange.java:142)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1256)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:622)
... 36 more
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (8 by maintainers)
I’m not sure but I might I’m on to something. I spent some more time investigating last night and I do see a discrepancy on how the Ant tasks create the
DatabaseConnection
and how other integrations do (like the CLI).The Ant tasks create the
JdbcConnection
manually via theDatabaseFactory.findCorrectDatabaseImplementation()
method passing an already createdJdbcConnection
object. In other integrations, theDatabaseFactory.openDatabase()
method is called which creates the connection object itself. There is much more sophisticated logic around selecting the proper connection type in thisDatabaseFactory
(via theConnectionServiceFactory
). This may explain why the Ant tasks are unaware of the pro connection types.I am going to dig a little more and see if this affects the exception. I will hopefully have more information soon. Regardless of whether this fixes the problem, that is definitely something to change.