-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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-core depends on gson: fails if not present #3672
Comments
Could you please provide us with a minimal reproduction? Please include the Flyway dependencies you are importing as well as a code snippet of your Flyway usage where possible. |
Hello, I'm embedding flyway-core-9.14.1 and flyway-mysql-9.14.1 jars in a tomcat application. Something like: @Startup
@Singleton(name="DatabaseInit")
@TransactionManagement(TransactionManagementType.BEAN)
public class DatabaseInit {
@Resource(name = "mydb", type = javax.sql.DataSource.class)
private DataSource db;
@PostConstruct
private void onStartup() {
boolean cleanDisabled = Boolean.parseBoolean(System.getProperty("flyway.cleanDisabled", "true"));
Flyway flyway = new Flyway(new FluentConfiguration()
.cleanDisabled(cleanDisabled)
.locations("classpath:com/mydb/db/migration")
.dataSource(db)
);
try {
MigrateResult migrateResult = flyway.migrate();
logger.info("{} migrations from {} to {}: {}",
migrateResult.migrationsExecuted,
migrateResult.initialSchemaVersion,
migrateResult.targetSchemaVersion,
migrateResult.success);
} catch (FlywayException e) {
logger.error("database migration failed", e);
}
}
} This used to not require any more dependencies. I see that in the pom the dependency jackson-dataformat-toml was not marked as optional, but it did not cause problems. |
Are you using a build tool like Maven or adding dependencies directly to the classpath? |
I'm using tools that do not rely on maven poms, but let me control the classpath. So basically manage the classpath manually, as well as the content of the war I deploy to tomcat.
|
Thank you for your additional information. I will take this back to the team as these dependencies are required for new functionality put into Flyway 9.17.0. However, the information above raises some thoughts which we need to consider moving forward. Thank you. |
Bumping plugin version from 9.16.0 to 9.19.1 solves the problem |
It would be great if flyway-core would not depend on new dependencies that are only used for optional features. Reporting is in my opinion not part of core and should be an extra dependency. |
Please note that for OSGi, that is a blocker, because flyway-core doesn't import com.google.gson (see Import-Package in MANIFEST.MF) but obviously tries to use it. Even when the gson bundle is correctly deployed and the package com.google.gson exported, flyway doesn't work. |
Hello, I reproduced the issue with flyway 10.11.0: flyway-core explicitly depends on gson java.util.ServiceConfigurationError: org.flywaydb.core.extensibility.Plugin: org.flywaydb.core.internal.reports.json.InfoResultDeserializer Unable to get public no-arg constructor |
And a new dependency on fasterxml jackson appeared too: |
Which version and edition of Flyway are you using?
Version 9.17.0
If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Yes
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
flyway-core java API
Which database are you using? (Type & version)
any
Which operating system are you using?
linux
What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)
Use flyway-core embedded in a tomcat service. Gson is not included in the application, which was fine until 9.17.0.
What did you expect to see?
Expected flyway-core to work embedded in the server, even if Gson is not present. Flyway itself has no reasons to impose a json marshaller or another.
What did you see instead?
Runtime failure, with a message like:
Another plugin depends on gson here:
org.flywaydb.core.internal.reports.json.MigrateResultDeserializer
.I see no easy way to disable the org.flywaydb.core.internal.reports.json.InfoResultDeserializer from flyway-core, but that could be an option.
Previous to commit 60a5ad1 Gson was a dependency for the cli, but not for flyway-core.
Removing the two problematic plugins from the
flyway-core\src\main\resources\META-INF\services\org.flywaydb.core.extensibility.Plugin
file, I can again use flyway-core api in my application without embedding the Gson library.The text was updated successfully, but these errors were encountered: