Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyway Maven Plugin can't find JDBC driver if the driver is a dependency with scope provided #1923

Closed
sparsick opened this issue Feb 13, 2018 · 4 comments

Comments

@sparsick
Copy link

@sparsick sparsick commented Feb 13, 2018

What version of Flyway are you using?

5.0.7

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)

Maven Plugin with following Maven Version

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Maven home: /home/sparsick/.sdkman/candidates/maven/current
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /home/sparsick/.sdkman/candidates/java/8u151-oracle/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-32-generic", arch: "amd64", family: "unix"

What database are you using (type & version)?

MySql 5.7.21-0ubuntu0.16.04.1

What operating system are you using?

Ubuntu 16.04 LTS based

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

I updated Flyway Version from 4.0.3 to 5.0.7. Following POM configuration, that works with 4.0.3, stopped working if calling mvn flyway:migrate

<dependencies>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>${flyway.version}</version>
            <configuration>
                <schemas>
                    <schema>flyway_demo</schema>
                </schemas>
                <user>flyway</user>
                <password>flyway</password>
                <url>jdbc:mysql://192.168.33.10:3306</url>
            </configuration>
        </plugin>

    </plugins>
</build>

After changing the scope of mysql-connector-java to 'compile' mvn flyway:migrate runs sucessfully

What did you expect to see?

BUILD SUCESSS

What did you see instead?

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building database-scripts 0.0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- flyway-maven-plugin:5.0.7:migrate (default-cli) @ database-scripts ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.725 s
[INFO] Finished at: 2018-02-13T12:09:12+01:00
[INFO] Final Memory: 13M/370M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:5.0.7:migrate (default-cli) on project database-scripts: org.flywaydb.core.api.FlywayException: Unable to instantiate JDBC driver: com.mysql.cj.jdbc.Driver => Check whether the jar file is present -> [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

@sparsick sparsick changed the title Fylway Maven Plugin can't find JDBC driver if the driver is a dependency with scope provided Flyway Maven Plugin can't find JDBC driver if the driver is a dependency with scope provided Feb 13, 2018
@axelfontaine axelfontaine added this to the Flyway 5.1.0 milestone Feb 13, 2018
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Feb 13, 2018
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Feb 13, 2018

Thanks for the detailed report. Fixed.

@sparsick
Copy link
Author

@sparsick sparsick commented Feb 14, 2018

My pleasure. Thanks for this fast fix.

@Miguel349
Copy link

@Miguel349 Miguel349 commented Oct 17, 2018

Hi,

Had the same problem in version 5.2.0 with mysqlconnector-connector for java in a spring boot project. Migrated to 5.1.0 and no issues, just so you know.

Thanks for the awesome tool.

Miguel.

@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Oct 18, 2018

@Miguel349 We can't reproduce this with 5.2.0. If the issue persists, please file a new issue with exact steps how to reproduce.

@flyway flyway locked as resolved and limited conversation to collaborators Oct 18, 2018
dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
…driver is a dependency with scope provided
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.