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

Spring Boot v3.0.13+ Unable to Load Flyway 10.0.0+ licenseKey #39431

Closed
cristianobinetti opened this issue Feb 7, 2024 · 3 comments
Closed
Labels
status: invalid An issue that we don't feel is valid

Comments

@cristianobinetti
Copy link

Problem Description:

The issue #38164 persists even after the fix released in Spring Boot 3.0.13 (v3.0.13 release note). The issue arises with Flyway versions 10.0.0 and above.

I have tested this issue with Spring Boot versions 3.0.13, 3.2.0, and the latest 3.2.2, alongside redgate flyway-core library versions 10.0.0 and the latest 10.7.1.

Issue Description:

The issue lies within the Spring Boot inner class FlywayConfiguration.class (FlywayAutoConfiguration$FlywayConfiguration.class), which attempts to invoke the method licenseKey(String) of the FluentConfiguration class within Flyway: org.flywaydb.core.api.configuration.FluentConfiguration.licenseKey(java.lang.String).

map.from(properties.getLicenseKey()).to((licenseKey) -> {  
    configuration.licenseKey(licenseKey);  
});

However, Flyway versions 10.0.0 and above have removed the licenseKey(String) method from the FluentConfiguration class. The minimum available version of com.redgate.flyway flyway-core is 10.0.0.

The resolution implemented in Spring Boot 3.0.13 (issues #38164 and #38266) primarily involves a syntax adjustment, transitioning from method reference to lambda expression. However, despite this modification, the underlying functionality remains unchanged. As a result, the issue continues to persist:

Before the fix (Spring Boot v3.0.0):

map.from(properties.getLicenseKey()).to(configuration::licenseKey);

After the fix (Spring Boot v3.0.13):

map.from(properties.getLicenseKey()).to((licenseKey) -> configuration.licenseKey(licenseKey));

However, configuration is an instance of the FluentConfiguration class, which no longer includes the licenseKey(String) method after the upgrade to redgate flyway version 10.0.0.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 7, 2024
@wilkinsona
Copy link
Member

Thanks for the report.

The problem that we believe we have fixed is that a failure would occur even if you hadn't set a property. This was due to the use of method references which would reference the method at runtime even if the relevant property hadn't been set. Having replaced those with lambdas, the problem should only occur if you've set a property that isn't compatible with a non-default version of Flyway as that will result in an attempt to call the method.

Can you confirm that you're setting spring.flyway.license-key and that your app starts if you remove it? It looks like the configuration of the licence key has been replaced with an environment variable that points to a permit so the property isn't needed with Flyway 10+.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Feb 7, 2024
@cristianobinetti
Copy link
Author

Hi,
Thank you for the prompt response.

Issue Confirmation:

I can confirm encountering the reported error when using both the spring.flyway.licenseKey and spring.flyway.license-key properties. Here's the error dump:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.lambda$configureProperties$41(FlywayAutoConfiguration.java:268)

The following method did not exist:

    'org.flywaydb.core.api.configuration.FluentConfiguration org.flywaydb.core.api.configuration.FluentConfiguration.licenseKey(java.lang.String)'

The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location:

    jar:file:/C:/Users/cristiano.binetti/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.13/spring-boot-autoconfigure-3.0.13.jar!/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class

The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations:

    jar:file:/C:/Users/cristiano.binetti/.m2/repository/com/redgate/flyway/flyway-core/10.7.1/flyway-core-10.7.1.jar!/org/flywaydb/core/api/configuration/FluentConfiguration.class

The called method's class hierarchy was loaded from the following locations:

    org.flywaydb.core.api.configuration.FluentConfiguration: file:/C:/Users/cristiano.binetti/.m2/repository/com/redgate/flyway/flyway-core/10.7.1/flyway-core-10.7.1.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration and org.flywaydb.core.api.configuration.FluentConfiguration


Process finished with exit code 0

Furthermore, without the property, the application starts normally, but with the following warning message:

[!INFO]
org.flywaydb.core.FlywayExecutor - You are not signed in to Flyway, to sign in please run auth

Authentication Information:

Referring to various authentication methods documented in the official Flyway documentation, it appears there are multiple ways to authorize Flyway, ordered by precedence:

[!INFO]

Authorization Precedence

There are multiple ways to authorize Flyway. The following list shows the order of precedence for authorization:

  1. REDGATE_LICENSING_PERMIT_PATH environment variable
  2. REDGATE_LICENSING_PERMIT environment variable
  3. License permit located in the Flyway CLI directory of the Redgate app data folder, saved to disk by running the auth command (both the online and offline flow save the license permit to the same location)
  4. License key

Since I'm exclusively using the spring.flyway.license-key property in the application.properties file, it should function properly.

(Note: I also attempted authentication via environment variables, using both FLYWAY_LICENSE_KEY (as shown in the flyway source code below) and REDGATE_LICENSING_PERMIT_PATH). However, it seems to be completely ignored by Flyway, as evidenced by the log message 'You are not signed in to Flyway, to sign in please run auth'.)

public String getConfigurationParameterFromEnvironmentVariable(String environmentVariable) {  
    return "FLYWAY_LICENSE_KEY".equals(environmentVariable) ? "flyway.licenseKey" : null;  
}

Flyway Ticket:

If it can help to better explain the error I'm facing, below is the ticket I opened to the Flyway support team:

Configuration via .properties file:

spring.flyway.licenseKey=FL01...

The issue arises due to the removal of the licenseKey(String) method from Flyway versions 10.0.0 and above within the FluentConfiguration class: org.flywaydb.core.api.configuration.FluentConfiguration.licenseKey(java.lang.String). Furthermore, the minimum available version of com.redgate.flyway flyway-core is 10.0.0. Consequently, the Spring Boot FlywayConfiguration.class is unable to set the license via the FluentConfiguration.licenseKey(String) method.

API Configuration:

Flyway flyway = Flyway.configure().load();

flyway.getConfigurationExtension(LicensingConfigurationExtension.class).setLicenseKey("FL01...");

In this scenario, the issue arises because the LicensingConfigurationExtension.class is not available in the com.redgate.flyway library. Instead, the library includes LicensingConfigurationExtensionStub.class, which features the following setLicenseKey(String) method:

public void setLicenseKey(String licenseKey) { 

    LOG.warn("Attempting to set a license key in Flyway open-source. Redgate features will not be available. Download Redgate Flyway at [https://rd.gt/3GGIXhh](https://rd.gt/3GGIXhh)"); 

}

Consequently, when attempting to set the license key through the API configuration, a warning log is generated as follows:
Pasted image 20240207114221

However, despite the warning, no authorization is actually performed.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 7, 2024
@wilkinsona
Copy link
Member

Thanks for the clarification.

Since I'm exclusively using the spring.flyway.license-key property in the application.properties file, it should function properly.

Unfortunately, that's not an expectation that we will meet. You're overriding Boot's default version of Flyway to a new major version that contains breaking changes in how the license key is configured. The earliest that we could adapt to that would be when we start using Flyway 10 by default but I'm not sure it will be possible as we won't have access to LicensingConfigurationExtension as it isn't in the OSS version. In the meantime, our goal is to make it possible to use Flyway 10 (#38164 has achieved that) but there may be some loss in functionality or things that you now have to configure yourself. The license key is one such thing.

You should remove the spring.flyway.license-key property from your application and configure it using one of the mechanisms that Flyway provides. If you want to do that programatically due the creation of the Flyway bean, you could do so using the FlywayConfigurationCustomizer by calling configuration.getPluginRegister().getPlugin(LicensingConfigurationExtension.class) and then configuring the extension as needed. If these mechanisms provided by Flyway do not work, you'll have to take that up with the Flyway maintainers as it's out of Spring Boot's control.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants