Syntax of calling with MongoDB

Hi everyone, I introduce myself, I am a new user who is starting to use Liquibase on some database categories, at the moment it is used for Oracle, MSSql and PostgreSQL and MongoDB. As for the first three apart from some initial difficulties (especially for non-Oracle) I was able to use liquibase, while for Mongo I read and reread everything I found and I realized that:

  1. A specific driver is required
  2. A specific plug-in is required
  3. Both must be put in the lib folder of the Liquibase jdk in use but when I go to make the call I always get the same error, that is:
    Starting Liquibase at 14:52:50 (version 4.1.0 #3 built at 2020-09-28 21:02+0000)
    Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find data base driver: mongodb.jdbc.MongoDriver
    For more information, please use the --logLevel flag
    [2021-04-23 14:52:50] SEVERE [liquibase.integration] Unexpected error running Li quibase: java.lang.RuntimeException: Cannot find database driver: mongodb.jdbc.M ongoDriver
    liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: ja va.lang.RuntimeException: Cannot find database driver: mongodb.jdbc.MongoDriver
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObje ct(CommandLineUtils.java:126)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1408)
    at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
    at liquibase.Scope.lambda$child$0(Scope.java:160)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:159)
    at liquibase.Scope.child(Scope.java:138)
    at liquibase.Scope.child(Scope.java:222)
    at liquibase.Scope.child(Scope.java:226)
    at liquibase.integration.commandline.Main$1.run(Main.java:360)
    at liquibase.integration.commandline.Main$1.run(Main.java:193)
    at liquibase.Scope.child(Scope.java:169)
    at liquibase.Scope.child(Scope.java:145)
    at liquibase.integration.commandline.Main.run(Main.java:193)
    at liquibase.integration.commandline.Main.main(Main.java:156)
    Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Ca nnot find database driver: mongodb.jdbc.MongoDriver
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.jav a:250)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java: 140)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObje ct(CommandLineUtils.java:91)
    … 14 more
    Caused by: java.lang.RuntimeException: Cannot find database driver: mongodb.jdbc .MongoDriver
    at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.jav a:192)
    … 16 more

This is the call I make:
/space/toolchain/liquibase4.1.0/liquibase --changeLogFile=changesetMarianoMongo.xlm --classpath=/space/toolchain/liquibase4.1.0/mongo-java-driver-3.12.7.jar --driver=mongodb.jdbc.MongoDriver --url=“jdbc:mongodb://ip:porta/nomeDB” --username=user --password=pwd history
Of course I hid the key parameters. The version of liquibase used is 4.1.0, the version of the plugin is liquibase-mongodb-4.3.3, the driver version is mongo-java-driver-3.12.7.jar and the jdk is 1.8
Can anyone help me understand where am I wrong and why? I also followed the instructions in this link to the letter: Using Liquibase with MongoDB | Liquibase Docs
Plus I just put the driver (or at least what I think is the call driver) where I put the others for the other db’s and call the one from the classtpath. Thanks everyone in advance.

Hi @Emix_69, if using CLI then just copy the missing dependencies to [liqiobase_installation]/lib folder.
Apart from liquibase-mongodb-4.x.x copy the dependencies mentioned here: GitHub - liquibase/liquibase-mongodb: MongoDB extension for Liquibase

And remove the --driver=mongodb.jdbc.MongoDriver from your command line as it is not correct, it will identify the right driver from the url starting with mongodb://

Please note currently having the mongodb jar in class path will prevent you work with other DB types. This is being fixed currently.

Ciao @alexandru.slobodcico
First of all thanks for the answer, if I am not mistaken I have already reported everything where it should go (but if I remember correctly they said to put it in the lib folder of the jdk you need. I am attaching (if I can) the screen of the installed libraries and where.
Then I wanted to ask you if you knew what the correct driver name was, I only found the one as an online name. Thank you.


As you can see from the screen, I put what it asks where it asks, but the error of the first post always comes back to me.
Then I wanted to ask you, what does it mean that I can’t use other DBs with Mongo drivers? Even with version 4.1.0? We need the ability to work simultaneously with the four db written in the first post: Oracle, PostegrSQL, MSSql and Mongo in fact. Thank you.

There is an issue when the MongoDB jar is in the classpath. There is discussion of the issue here:

Hello and thanks.
I had already read something, now that you submitted it to me, I have read it all, but it does not “solve” my problem, that is, in addition to having the problem you signal, I also have the problem that the driver in the call does not “recognize” me and therefore gives me the error above.

@Emix_69 Have you found a solution for this?

Hi @Lyks. Unfortunately I have not found a solution other than to manage them separately. I noticed that with Mongo it has this defect, that is, it works indiscriminately on all the other DBs, but on Mongo or alone or it is not read, unfortunately and those errors return to you which are not true errors, because they are misleading.