liquibase.exception.MigrationFailedException: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have a change set that verifies if an Oracle view exists in another schema/catalog. I log in as my "liquibase" user who defaults to the "liquibase" schema. To reproduce the problem, I have the following change set that generates an error: {code:xml} <changeSet id="Test viewExists" author="test" dbms="oracle"> <preConditions onFailMessage="The USER_SDO_GEOM_METADATA does actually exist"> <viewExists viewName="USER_SDO_GEOM_METADATA" catalogName="MDSYS" schemaName="MDSYS" /> </preConditions> </changeSet> {code} I've tried setting either {{catalogName}} or {{schemaName}} to "MDSYS" without luck. The precondition always generates this SQL: {code:sql} SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='USER_SDO_GEOM_METADATA' AND OWNER='LIQUIBASE' {code} which results in this error: {code} DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Running Changeset:add-column-create-index-drop-column.xml::Test viewExists::test DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Changeset add-column-create-index-drop-column.xml::Test viewExists::test DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Executing QUERY database command: SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='USER_SDO_GEOM_METADATA' AND OWNER='LIQUIBASE' SEVERE 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Change Set add-column-create-index-drop-column.xml::Test viewExists::test failed. Error: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row liquibase.exception.MigrationFailedException: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row at liquibase.changelog.ChangeSet.execute(ChangeSet.java:514) at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.update(Liquibase.java:200) at liquibase.Liquibase.update(Liquibase.java:181) at liquibase.ext.spatial.LiquibaseIT.testLiquibaseUpdate(LiquibaseIT.java:183) at sun.reflect.GeneratedMethodAccessor268.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: liquibase.exception.PreconditionErrorException: Precondition Error at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:66) at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:201) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:471) ... 28 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@//192.168.0.21:1521/pdb2 view with liquibase.statement.core.GetViewDefinitionStatement@55336e6 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:95) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:60) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:134) at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:88) at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:60) ... 31 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@2ce17337 but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:155) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:862) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 43 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:153) ... 47 more {code}
    via by Lonny Jacobson,
  • I have a change set that verifies if an Oracle view exists in another schema/catalog. I log in as my "liquibase" user who defaults to the "liquibase" schema. To reproduce the problem, I have the following change set that generates an error: {code:xml} <changeSet id="Test viewExists" author="test" dbms="oracle"> <preConditions onFailMessage="The USER_SDO_GEOM_METADATA does actually exist"> <viewExists viewName="USER_SDO_GEOM_METADATA" catalogName="MDSYS" schemaName="MDSYS" /> </preConditions> </changeSet> {code} I've tried setting either {{catalogName}} or {{schemaName}} to "MDSYS" without luck. The precondition always generates this SQL: {code:sql} SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='USER_SDO_GEOM_METADATA' AND OWNER='LIQUIBASE' {code} which results in this error: {code} DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Running Changeset:add-column-create-index-drop-column.xml::Test viewExists::test DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Changeset add-column-create-index-drop-column.xml::Test viewExists::test DEBUG 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Executing QUERY database command: SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='USER_SDO_GEOM_METADATA' AND OWNER='LIQUIBASE' SEVERE 1/18/15 9:24 AM: liquibase: add-column-create-index-drop-column.xml: add-column-create-index-drop-column.xml::Test viewExists::test: Change Set add-column-create-index-drop-column.xml::Test viewExists::test failed. Error: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row liquibase.exception.MigrationFailedException: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row at liquibase.changelog.ChangeSet.execute(ChangeSet.java:514) at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.update(Liquibase.java:200) at liquibase.Liquibase.update(Liquibase.java:181) at liquibase.ext.spatial.LiquibaseIT.testLiquibaseUpdate(LiquibaseIT.java:183) at sun.reflect.GeneratedMethodAccessor268.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: liquibase.exception.PreconditionErrorException: Precondition Error at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:66) at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:201) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:471) ... 28 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@//192.168.0.21:1521/pdb2 view with liquibase.statement.core.GetViewDefinitionStatement@55336e6 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:95) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:60) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:134) at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:88) at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:60) ... 31 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@2ce17337 but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:155) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:862) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 43 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:153) ... 47 more {code}
    via by Lonny Jacobson,
  • Table exists precondition fails with the following exception: {code} DEBUG 3/20/15 4:12 PM: liquibase: <skipped> Executing QUERY database command: SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='*_<VIEW_NAME>_*' AND OWNER='_*<CURRENT_USER>*_' SEVERE 3/20/15 4:12 PM: liquibase: <skipped> Change Set <skipped> failed. Error: Migration failed for change set <skipped> Reason: <skipped> liquibase.precondition.core.TableExistsPrecondition@333f8b04 : Empty result set, expected one row liquibase.exception.MigrationFailedException: Migration failed for change set <skipped> Reason: <skipped> liquibase.precondition.core.TableExistsPrecondition@333f8b04 : Empty result set, expected one row at liquibase.changelog.ChangeSet.execute(ChangeSet.java:514) at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:50) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.update(Liquibase.java:200) at org.liquibase.maven.plugins.LiquibaseUpdate.doUpdate(LiquibaseUpdate.java:33) at org.liquibase.maven.plugins.AbstractLiquibaseUpdateMojo.performLiquibaseTask(AbstractLiquibaseUpdateMojo.java:24) at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:377) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216) at org.apache.maven.cli.MavenCli.main(MavenCli.java:160) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: liquibase.exception.PreconditionErrorException: Precondition Error at liquibase.precondition.core.TableExistsPrecondition.check(TableExistsPrecondition.java:65) at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:201) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:471) ... 27 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@<host>:<port>/<service_name> view with liquibase.statement.core.GetViewDefinitionStatement@13fabfb3 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:100) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:189) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:267) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:289) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:221) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:203) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:70) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:45) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:134) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:123) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:111) at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:101) at liquibase.precondition.core.TableExistsPrecondition.check(TableExistsPrecondition.java:59) ... 30 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@58815902 but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:155) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:862) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 47 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:153) ... 51 more {code} Analysis showed that snapshot creation attempt was made during table existence check, and has eventually failed during attempt to get a View definition: {{liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(DatabaseObject, DatabaseSnapshot)}}: {code} String rawViewName = row.getString("TABLE_NAME"); String rawSchemaName = StringUtils.trimToNull(row.getString("TABLE_SCHEM")); String rawCatalogName = StringUtils.trimToNull(row.getString("TABLE_CAT")); {code} After lines above are executed, {{rawSchemaName}} is <APPROPRIATE_VIEW_SCHEMA> and {{rawCatalogName}} is null. Next, View object itself is created: {code} View view = new View().setName(cleanNameFromDatabase(rawViewName, database)); view.setRemarks(remarks); CatalogAndSchema schemaFromJdbcInfo = ((AbstractJdbcDatabase) database).getSchemaFromJdbcInfo(rawCatalogName, rawSchemaName); view.setSchema(new Schema(schemaFromJdbcInfo.getCatalogName(), schemaFromJdbcInfo.getSchemaName())); {code} {{liquibase.database.AbstractJdbcDatabase.getSchemaFromJdbcInfo(String, String)}} calls {{liquibase.CatalogAndSchema.customize(Database)}} that eventually calls {{liquibase.CatalogAndSchema.standardize(Database)}}. This method considers catalog/schema names to be "in the wrong order" (Oracle does not support schemas while schema name is not null and catalog name is null) and swaps their values: {code} if (accordingTo.supportsSchemas()) { if (schemaName != null && schemaName.equalsIgnoreCase(accordingTo.getDefaultSchemaName())) { schemaName = null; } } else { if (catalogName == null && schemaName != null) { //had names in the wrong order catalogName = schemaName; } schemaName = catalogName; } {code} {{liquibase.CatalogAndSchema.customize(Database)}} also sets {{schemaName}} to the default value (<CURRENT_USER>): {code} public CatalogAndSchema customize(Database accordingTo) { CatalogAndSchema standard = standardize(accordingTo); String catalogName = standard.getCatalogName(); String schemaName = standard.getSchemaName(); <skipped> if (schemaName == null) { schemaName = accordingTo.getDefaultSchemaName(); } <skipped> return new CatalogAndSchema(catalogName, schemaName); } {code} Hence, catalog name becomes correct schema name and schema name becomes <CURRENT_USER>.{{liquibase.sqlgenerator.core.GetViewDefinitionGeneratorOracle.generateSql(GetViewDefinitionStatement, Database, SqlGeneratorChain)}} uses schema name (again, schemas are not supported by Oracle DB) instead of a catalog in its statement: {code} return new Sql[]{ new UnparsedSql("SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='" + statement.getViewName().toUpperCase() + "' AND OWNER='" + schema.getSchemaName() + "'") }; {code}
    via by Alexander Kiselyov,
  • Table exists precondition fails with the following exception: {code} DEBUG 3/20/15 4:12 PM: liquibase: <skipped> Executing QUERY database command: SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='*_<VIEW_NAME>_*' AND OWNER='_*<CURRENT_USER>*_' SEVERE 3/20/15 4:12 PM: liquibase: <skipped> Change Set <skipped> failed. Error: Migration failed for change set <skipped> Reason: <skipped> liquibase.precondition.core.TableExistsPrecondition@333f8b04 : Empty result set, expected one row liquibase.exception.MigrationFailedException: Migration failed for change set <skipped> Reason: <skipped> liquibase.precondition.core.TableExistsPrecondition@333f8b04 : Empty result set, expected one row at liquibase.changelog.ChangeSet.execute(ChangeSet.java:514) at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:50) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.update(Liquibase.java:200) at org.liquibase.maven.plugins.LiquibaseUpdate.doUpdate(LiquibaseUpdate.java:33) at org.liquibase.maven.plugins.AbstractLiquibaseUpdateMojo.performLiquibaseTask(AbstractLiquibaseUpdateMojo.java:24) at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:377) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216) at org.apache.maven.cli.MavenCli.main(MavenCli.java:160) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: liquibase.exception.PreconditionErrorException: Precondition Error at liquibase.precondition.core.TableExistsPrecondition.check(TableExistsPrecondition.java:65) at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:201) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:471) ... 27 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@<host>:<port>/<service_name> view with liquibase.statement.core.GetViewDefinitionStatement@13fabfb3 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:100) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:189) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:267) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:289) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:221) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:203) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:70) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:45) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:134) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:123) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:111) at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:101) at liquibase.precondition.core.TableExistsPrecondition.check(TableExistsPrecondition.java:59) ... 30 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@58815902 but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:155) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:862) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 47 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:153) ... 51 more {code} Analysis showed that snapshot creation attempt was made during table existence check, and has eventually failed during attempt to get a View definition: {{liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(DatabaseObject, DatabaseSnapshot)}}: {code} String rawViewName = row.getString("TABLE_NAME"); String rawSchemaName = StringUtils.trimToNull(row.getString("TABLE_SCHEM")); String rawCatalogName = StringUtils.trimToNull(row.getString("TABLE_CAT")); {code} After lines above are executed, {{rawSchemaName}} is <APPROPRIATE_VIEW_SCHEMA> and {{rawCatalogName}} is null. Next, View object itself is created: {code} View view = new View().setName(cleanNameFromDatabase(rawViewName, database)); view.setRemarks(remarks); CatalogAndSchema schemaFromJdbcInfo = ((AbstractJdbcDatabase) database).getSchemaFromJdbcInfo(rawCatalogName, rawSchemaName); view.setSchema(new Schema(schemaFromJdbcInfo.getCatalogName(), schemaFromJdbcInfo.getSchemaName())); {code} {{liquibase.database.AbstractJdbcDatabase.getSchemaFromJdbcInfo(String, String)}} calls {{liquibase.CatalogAndSchema.customize(Database)}} that eventually calls {{liquibase.CatalogAndSchema.standardize(Database)}}. This method considers catalog/schema names to be "in the wrong order" (Oracle does not support schemas while schema name is not null and catalog name is null) and swaps their values: {code} if (accordingTo.supportsSchemas()) { if (schemaName != null && schemaName.equalsIgnoreCase(accordingTo.getDefaultSchemaName())) { schemaName = null; } } else { if (catalogName == null && schemaName != null) { //had names in the wrong order catalogName = schemaName; } schemaName = catalogName; } {code} {{liquibase.CatalogAndSchema.customize(Database)}} also sets {{schemaName}} to the default value (<CURRENT_USER>): {code} public CatalogAndSchema customize(Database accordingTo) { CatalogAndSchema standard = standardize(accordingTo); String catalogName = standard.getCatalogName(); String schemaName = standard.getSchemaName(); <skipped> if (schemaName == null) { schemaName = accordingTo.getDefaultSchemaName(); } <skipped> return new CatalogAndSchema(catalogName, schemaName); } {code} Hence, catalog name becomes correct schema name and schema name becomes <CURRENT_USER>.{{liquibase.sqlgenerator.core.GetViewDefinitionGeneratorOracle.generateSql(GetViewDefinitionStatement, Database, SqlGeneratorChain)}} uses schema name (again, schemas are not supported by Oracle DB) instead of a catalog in its statement: {code} return new Sql[]{ new UnparsedSql("SELECT TEXT FROM ALL_VIEWS WHERE upper(VIEW_NAME)='" + statement.getViewName().toUpperCase() + "' AND OWNER='" + schema.getSchemaName() + "'") }; {code}
    via by Alexander Kiselyov,
  • Liquibase update error
    via Stack Overflow by user821863
    ,
  • We are trying to use some JUnit test for our application... everything goes fine when we start with an empty database and we only run the create sentences, but when we try to run the case more than once and use the dropAll method the following error appears: INFO 8/11/14 12:11 PM: liquibase: Successfully released change log lock liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.Liquibase.dropAll(Liquibase.java:676) at liquibase.Liquibase.dropAll(Liquibase.java:658) at com.accsa.domus.business.db.Update.blank(Update.java:85) at com.accsa.domus.business.db.Update.main(Update.java:95) Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:732) at liquibase.Liquibase.dropAll(Liquibase.java:671) ... 3 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:77) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:153) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:226) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:248) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:185) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:167) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:56) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:33) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:22) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:107) at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:729) ... 4 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:152) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:162) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:157) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:855) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 20 more Exception in thread "main" liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.Liquibase.dropAll(Liquibase.java:676) at liquibase.Liquibase.dropAll(Liquibase.java:658) at com.accsa.domus.business.db.Update.blank(Update.java:85) at com.accsa.domus.business.db.Update.main(Update.java:95) Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:732) at liquibase.Liquibase.dropAll(Liquibase.java:671) ... 3 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:77) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:153) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:226) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:248) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:185) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:167) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:56) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:33) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:22) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:107) at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:729) ... 4 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:152) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:162) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:157) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:855) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 20 more There are several issues similar to these over internet, but after following all the recommendations we couldn't find a solution. The database has no views, but debugging de code we saw that some view methods are called using tables as parameters. Any help would be great!
    via by Nicolás Orbes,
  • we upgraded from 2.0.5 to 3.4.2 Liquibase last week and the below changeset is working fine with 2.0.5. I see a similar error documented for previous releases in a JIRA ticket(CORE-2198). I have a change set that verifies if an Oracle view exists in a schema(DYNCT1) and drop it if it exists. I log in as my "liquibase" user which defaults to the "system" schema. To reproduce the problem, I have the following change set that generates an error: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> <property name="changeSetType" value="DDL"/> <changeSet author="AAAA.AAAAA" id="1614" failOnError="true"> <preConditions onFail="MARK_RAN"> <viewExists schemaName="DYNCT1" viewName="SKU" /> </preConditions> <comment>[OPT-1257] Drop View</comment> <dropView schemaName="DYNCT1" viewName="V_A" /> <rollback> CREATE VIEW "DYNCT1"."V_A" ("SKU_ID", "PROMO_ID", "BONUS_ITEM_SKU") AS SELECT DISTINCT SKU.SKU_ID, SKU.PROMO_ID, SKU.BONUS_ITEM_SKU FROM DYNCT1.A SKU; GRANT SELECT ON dynct1.V_A TO dyncat_objsel_role; </rollback> </changeSet> </databaseChangeLog> The changeset is failing with the below error. Reason: [java] src/main/resources/changeLog.xml : liquibase.precondition.core.ViewExistsPrecondition@59d4cd39 : Empty result set, expected one row [java] [java] liquibase.exception.MigrationFailedException: Migration failed for change set releases/1614/atg/dynct1/drop_view_v_a.xml::1614::venkatrama.kamaraj: [java] Reason: [java] src/main/resources/changeLog.xml : liquibase.precondition.core.ViewExistsPrecondition@59d4cd39 : Empty result set, expected one row [java] [java] at liquibase.changelog.ChangeSet.execute(ChangeSet.java:513) [java] at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51) [java] at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) [java] at liquibase.Liquibase.update(Liquibase.java:212) [java] at liquibase.Liquibase.update(Liquibase.java:192) [java] at liquibase.Liquibase.update(Liquibase.java:327) [java] at liquibase.Liquibase.updateTestingRollback(Liquibase.java:1069) [java] at liquibase.Liquibase.updateTestingRollback(Liquibase.java:1061) [java] at liquibase.integration.commandline.Main.doMigration(Main.java:1167) [java] at liquibase.integration.commandline.Main.run(Main.java:180) [java] at liquibase.integration.commandline.Main.main(Main.java:99) [java] Caused by: liquibase.exception.PreconditionErrorException: Precondition Error [java] at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:66) [java] at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) [java] at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:202) [java] at liquibase.changelog.ChangeSet.execute(ChangeSet.java:470) [java] ... 10 more [java] Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@localhost:1541:OV1ATG view with liquibase.statement.core.GetViewDefinitionStatement@421e361 [java] at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:100) [java] at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) [java] at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) [java] at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) [java] at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) [java] at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:194) [java] at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:70) [java] at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:44) [java] at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:21) [java] at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:150) [java] at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:158) [java] at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:108) [java] at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:60) [java] ... 13 more [java] Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@658c5a19 but got 0 [java] at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:140) [java] at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151) [java] at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:146) [java] at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:867) [java] at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) [java] ... 25 more [java] Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row [java] at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) [java] at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:138) [java] ... 29 more
    via by Bhvani Prasad Atluri,
  • We are trying to use some JUnit test for our application... everything goes fine when we start with an empty database and we only run the create sentences, but when we try to run the case more than once and use the dropAll method the following error appears: INFO 8/11/14 12:11 PM: liquibase: Successfully released change log lock liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.Liquibase.dropAll(Liquibase.java:676) at liquibase.Liquibase.dropAll(Liquibase.java:658) at com.accsa.domus.business.db.Update.blank(Update.java:85) at com.accsa.domus.business.db.Update.main(Update.java:95) Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:732) at liquibase.Liquibase.dropAll(Liquibase.java:671) ... 3 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:77) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:153) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:226) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:248) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:185) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:167) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:56) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:33) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:22) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:107) at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:729) ... 4 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:152) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:162) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:157) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:855) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 20 more Exception in thread "main" liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.Liquibase.dropAll(Liquibase.java:676) at liquibase.Liquibase.dropAll(Liquibase.java:658) at com.accsa.domus.business.db.Update.blank(Update.java:85) at com.accsa.domus.business.db.Update.main(Update.java:95) Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:732) at liquibase.Liquibase.dropAll(Liquibase.java:671) ... 3 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:mysql://10.5.210.245:3306/domus_migracion view with liquibase.statement.core.GetViewDefinitionStatement@6debbf97 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:77) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:153) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:226) at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:248) at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:185) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:167) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:56) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:33) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:22) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:107) at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:729) ... 4 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:152) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:162) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:157) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:855) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 20 more There are several issues similar to these over internet, but after following all the recommendations we couldn't find a solution. The database has no views, but debugging de code we saw that some view methods are called using tables as parameters. Any help would be great!
    via by Nicolás Orbes,
  • When Liquibase prints the message {code} 2016-07-19 09:08:27,861 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... 2016-07-19 09:08:37,865 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... 2016-07-19 09:08:47,868 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... 2016-07-19 09:08:57,872 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... {code} and someone deletes the lock entry in the databasechangeloglock table, Liquibase fails with an error: {code} 2016-07-19 09:08:47,868 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... 2016-07-19 09:08:57,872 [ INFO] [main] () {} (liquibase): Waiting for changelog lock.... 2016-07-19 09:09:07,876 [ WARN] [main] () {} (AnnotationConfigEmbeddedWebApplicationContext): Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LockException: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.SelectFromDatabaseChangeLogLockStatement@406a406c but got 0 2016-07-19 09:09:07,906 [ERROR] [main] () {} (SpringApplication): Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LockException: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.SelectFromDatabaseChangeLogLockStatement@406a406c but got 0 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at com.daimler.daivb.core.InitExecApplication.run(InitExecApplication.java:36) at com.daimler.daivb.core.DaivbSpringApplication.run(DaivbSpringApplication.java:50) at com.daimler.daivb.core.DaivbSpringApplication.run(DaivbSpringApplication.java:29) at com.daimler.daivb.vhp.VhpApplication.main(VhpApplication.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54) at java.lang.Thread.run(Thread.java:745) Caused by: liquibase.exception.LockException: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.SelectFromDatabaseChangeLogLockStatement@406a406c but got 0 at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:225) at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:164) at liquibase.Liquibase.update(Liquibase.java:196) at liquibase.Liquibase.update(Liquibase.java:192) at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:434) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:391) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ... 25 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.SelectFromDatabaseChangeLogLockStatement@406a406c but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:140) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:146) at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:200) ... 32 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:138) ... 35 more {code}
    via by Michael Rumpf,
    • liquibase.exception.MigrationFailedException: Migration failed for change set add-column-create-index-drop-column.xml::Test viewExists::test: Reason: add-column-create-index-drop-column.xml : liquibase.precondition.core.ViewExistsPrecondition@1a3938c5 : Empty result set, expected one row at liquibase.changelog.ChangeSet.execute(ChangeSet.java:514) at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.update(Liquibase.java:200) at liquibase.Liquibase.update(Liquibase.java:181) at liquibase.ext.spatial.LiquibaseIT.testLiquibaseUpdate(LiquibaseIT.java:183) at sun.reflect.GeneratedMethodAccessor268.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: liquibase.exception.PreconditionErrorException: Precondition Error at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:66) at liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43) at liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:201) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:471) ... 28 more Caused by: liquibase.exception.DatabaseException: Error getting jdbc:oracle:thin:@//192.168.0.21:1521/pdb2 view with liquibase.statement.core.GetViewDefinitionStatement@55336e6 at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:95) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63) at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50) at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163) at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:60) at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37) at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126) at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:134) at liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:88) at liquibase.precondition.core.ViewExistsPrecondition.check(ViewExistsPrecondition.java:60) ... 31 more Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@2ce17337 but got 0 at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:155) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161) at liquibase.database.AbstractJdbcDatabase.getViewDefinition(AbstractJdbcDatabase.java:862) at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:75) ... 43 more Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:141) at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:153) ... 47 more
    No Bugmate found.