Liquibase mongo java driver, resulting in errors

I am getting the following error while creating the mongo collection with liquibase and i am using the liquibase-mongodb-4.9.0.jar and mongo-java-driver-3.9.1.jar drivers

Liquibase version 4.9.0

its working fine for postgresql and mysql.Having issues in mongodb only

[2022-03-30 08:11:26] FINE [com.mongodb.diagnostics.logging.JULLogger log] Closing connection connectionId{localValue:2, serverValue:30}
[2022-03-30 08:11:26] FINE [com.mongodb.diagnostics.logging.JULLogger log] Closing connection connectionId{localValue:1, serverValue:29}
[2022-03-30 08:11:26] SEVERE [liquibase.integration] ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:51)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:21)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:325)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:291)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:80)
Caused by: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
at liquibase.integration.commandline.Main$1.run(Main.java:443)
at liquibase.integration.commandline.Main$1.run(Main.java:221)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.Main.run(Main.java:221)
at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:32)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
… 14 more
Caused by: java.lang.NoSuchMethodError: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.checkResponse(AbstractRunCommandStatement.java:78)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:60)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:55)
at liquibase.ext.mongodb.statement.ListCollectionNamesStatement.queryForList(ListCollectionNamesStatement.java:79)
at liquibase.ext.mongodb.statement.CountCollectionByNameStatement.queryForLong(CountCollectionByNameStatement.java:44)
at liquibase.ext.mongodb.statement.CountCollectionByNameStatement.queryForLong(CountCollectionByNameStatement.java:33)
at liquibase.nosql.executor.NoSqlExecutor.queryForLong(NoSqlExecutor.java:111)
at liquibase.nosql.executor.NoSqlExecutor.queryForLong(NoSqlExecutor.java:104)
at liquibase.ext.mongodb.lockservice.MongoLockService.existsRepository(MongoLockService.java:85)
at liquibase.nosql.lockservice.AbstractNoSqlLockService.hasDatabaseChangeLogLockTable(AbstractNoSqlLockService.java:305)
at liquibase.nosql.lockservice.AbstractNoSqlLockService.init(AbstractNoSqlLockService.java:93)
at liquibase.nosql.lockservice.AbstractNoSqlLockService.acquireLock(AbstractNoSqlLockService.java:155)
at liquibase.nosql.lockservice.AbstractNoSqlLockService.waitForLock(AbstractNoSqlLockService.java:119)
at liquibase.Liquibase.lambda$update$1(Liquibase.java:214)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.Liquibase.runInScope(Liquibase.java:2405)
at liquibase.Liquibase.update(Liquibase.java:211)
at liquibase.Liquibase.update(Liquibase.java:197)
at liquibase.integration.commandline.Main.doMigration(Main.java:1870)
at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:398)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.integration.commandline.Main$1.run(Main.java:397)
… 20 more

Unexpected error running Liquibase: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’

liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unexpected error running Liquibase: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:51)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:21)

1 Like

Welcome to the Liquibase Community, @MuraliKrishna - and thanks for posting this issue. I am researching to try to find an answer for you. When we have something to share, I or one of my teammates will reply again to follow up.

Regards,
Tabby

1 Like

This seems to be the root cause:

java.lang.NoSuchMethodError: ‘java.util.List org.bson.Document.getList(java.lang.Object, java.lang.Class)’
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.checkResponse(AbstractRunCommandStatement.java:78)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:60)
at liquibase.ext.mongodb.statement.AbstractRunCommandStatement.run(AbstractRunCommandStatement.java:55)
at liquibase.ext.mongodb.statement.ListCollectionNamesStatement.queryForList(ListCollectionNamesStatement.java:79)
at liquibase.ext.mongodb.statement.CountCollectionByNameStatement.queryForLong(CountCollectionByNameStatement.java:44)

It looks like the problem is that l.e.mongodb.statement.AbstractRunCommandStatement.java#L78 is calling org.bson.Document.getList(java.lang.Object, java.lang.Class) but this method no longe exists in the bson library?

Strange, because the method being called seems to be in the docs.

2 Likes

This should likely be [filed as an issue on git hub liquibase/liquibase-mongodb/issues/, but be sure to read How to report an issue in Liquibase.

2 Likes