Maven connect with Oracle jdbc driver to external database problem

Liquibase version: 4.0.0

Maven version: Apache Maven 3.6.3

Oracle db version: Oracle Database 12c Standard Edition

I’m trying to use ojdbc8.jar in maven without setting the classpath: ojdbc8.jar in the liquibase.properties file. I found here that you can upload the ojdbc8.jar in your local maven repository.

I did this with the following command:


mvn install:install-file -Dfile=C:\path\to\ojdbc8.jar -DgroupId="com.oracle.jdbc" -DartifactId=ojdbc8 -Dversion="12.2.0.1" -Dpackaging=jar

Verified the result and I can now find the following file: C:\Users\cft\.m2\repository\com\oracle\jdbc\ojdbc8\12.2.0.1\ojdbc8-12.2.0.1.jar.

Now when I run the command:


mvn liquibase:update -P release-abap-test

I get the error Possibly the wrong driver for the given database URL. This error occurs for all databases that are not on my local machine. The same command works fine for a database that is on my local machine. Executing a direct liquibase update including a reference to a local copy of the ojdbc8.jar command works fine for all databases that are not on my local machine. What am I doing wrong here?


[INFO] Liquibase Community 4.0.0 by Datical

[INFO] Starting Liquibase at 15:01:55 (version 4.0.0 #19 built at 2020-07-13 19:45+0000)

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  3.470 s

[INFO] Finished at: 2020-08-19T15:01:57+02:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.0.0:update (default-cli) on project liquibase-poc:

[ERROR] Error setting up or running Liquibase:

[ERROR] liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:oracle:thin:@//bk-rdk-ota-ora-scan:1521/BKTST with driver oracle.jdbc.OracleDriver.  Possibly the wrong driver for the given database URL

[ERROR] -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

My project contains in the most basic form the following files.


Liquibase/

├── liquibase.properties 

├── master.changelog.xml

└── pom.xml

The content of my liquibase.properties file:


changeLogFile=master.changelog.xml

driver: oracle.jdbc.OracleDriver

The content of my master.changelog.xml:


<?xml version="1.0" encoding="utf-8" ?>

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

    <include file="pathtoanotherxmlfile.changelog.xml" relativeToChangelogFile="true"/>

    <include file="pathtojustanotherxmlfile.changelog.xml" relativeToChangelogFile="true"/>

</databaseChangeLog>

The content of my pom.xml:


<project xmlns="http://maven.apache.org/POM/4.0.0"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.liquibase-poc</groupId>

    <artifactId>liquibase-poc</artifactId>

    <version>1.0</version>

    <packaging>jar</packaging>

    <name>liquibase-poc</name>

    <dependencies>

        <!-- Oracle -->

        <dependency>

            <groupId>com.oracle.jdbc</groupId>

            <artifactId>ojdbc8</artifactId>

            <version>12.2.0.1</version>

        </dependency>

        <!-- Liquibase -->

        <dependency>

            <groupId>org.liquibase</groupId>

            <artifactId>liquibase-core</artifactId>

            <version>4.0.0</version>

        </dependency>

    </dependencies>

    <profiles>

        <profile>

            <id>release-abap-test</id>

            <build>

                <plugins>

                    <!-- Use Java 1.8 -->

                    <plugin>

                        <groupId>org.apache.maven.plugins</groupId>

                        <artifactId>maven-compiler-plugin</artifactId>

                        <version>2.5.1</version>

                        <configuration>

                            <source>1.8</source>

                            <target>1.8</target>

                        </configuration>

                    </plugin>

                    <plugin>

                        <groupId>org.liquibase</groupId>

                        <artifactId>liquibase-maven-plugin</artifactId>

                        <version>4.0.0</version>

                        <configuration>

                            <contexts>CZ</contexts>

                            <labels>ABAP</labels>

                            <dropFirst>false</dropFirst>

                            <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>

                            <url>jdbc:oracle:thin:@//bk-rdk-ota-ora-scan:1521/BKTST</url>

                            <username>user</username>

                            <password>pass</password>

                            <propertyFile>liquibase.properties</propertyFile>

                        </configuration>

                        <executions>

                            <execution>

                                <phase>process-resources</phase>

                                <goals>

                                    <goal>update</goal>

                                </goals>

                            </execution>

                        </executions>

                    </plugin>

                    <plugin>

                        <groupId>org.apache.maven.plugins</groupId>

                        <artifactId>maven-surefire-plugin</artifactId>

                        <version>2.19.1</version>

                        <configuration>

                            <skipTests>true</skipTests>

                        </configuration>

                    </plugin>

                </plugins>

            </build>

        </profile>

</project>

After a lot of frustration it turns out that this problem was caused by an incorrect password… When you cannot connect with maven to an oracle database the only error message you get is that it is possibly the wrong driver. However, if you run it directly with liquibase you get a more meaningfull message!