Options

Integrating Flyway with my Spring Boot Java application - unsupported Oracle version 12.2

I am trying to integrate Flyway community edition into my Spring Boot 3.1.0 application using Gradle to configure/build.

I have added the following in my dependencies section of the build.gradle file:

implementation group: 'org.flywaydb', name: 'flyway-core'

and refreshed the Gradle properties.

When I try to run the application, I get the following error:

...
Caused by: org.flywaydb.core.internal.license.FlywayEditionUpgradeRequiredException: Flyway Teams Edition or Oracle upgrade required: Oracle 12.2 is no longer supported by Flyway Community Edition, but still supported by Flyway Teams Edition.

The version of the database is 12.2.0.1.0, so I'm guessing this is the issue.

I've found the following Stack Overflow message: https://stackoverflow.com/questions/61951224/flyway-with-oracle/77332322#77332322

In which one responder says that with Flyway Community Edition 10.0.0, all Oracle database versions are now supported.
I think I'm using version 10.0.0. When I change the dependency entry in the build.gradle file to include the version 10.0.0, then I get a different error when trying to start the application:

Caused by: org.flywaydb.core.api.FlywayException: Unsupported Database: Oracle 12.2

Can I use Flyway Community Edition with Oracle 12.2?




Best Answer

Answers

  • Options
    Hello MarkEHansen,

    Your interpretation is correct. My anticipation is that you may have updated your flyway core version but your Oracle dependency may not be on v10 and that's where the change was introduced.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    We've moved back to version 9.16.3 and that appears to work with Spring Boot, but still cannot connect to the Oracle 12.2 database. We're looking for a way to run Flyway with Spring Boot and connect to Oracle databases as old as 12.2.
  • Options
    I understand the objective.

    Regarding the version, what I was trying ot establish is, when you're altering the core version, are oyu also altering the dependancy?

    E.G
    dependencies {
        implementation "org.flywaydb:flyway-database-oracle/10.0.1"
    }
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    edited November 17, 2023 9:47PM
    I'm not setting the flyway-database-oracle dependency. No matter what I tried there, when I include that, the gradle refresh fails. If I leave that out, I'm able to talk to our 19.x version Oracle databases.
  • Options
    Peter_LawsPeter_Laws Posts: 220 Silver 2
    edited November 20, 2023 10:24AM
    MarkEHansen, would you be willing to share your build file for us to check, we're evidentially missing something here.
    Happy to create a support issue for you to do so securely.

    In what way did the dependency cause the refresh to fail please?
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    Thank you for your help, Peter. I'm not sure which part you're asking about. I think to be able to access Oracle 12.2 databases, I would need to be using Flyway version 10.0.0, but it seems Flyway 10.0.0 is not supported by Spring Boot 3.5. When I try to use Flyway 10.0.0 with Spring Boot, I get errors when Spring Boot is initializing. Is this what you are talking about?

    The other point is about the Oracle database driver. When I'm using Flyway 9.16.3, then I don't know what version of the flyway-database-oracle dependency to include. I tried 9.16.3 and it was not found. When I tried 10.0.0, I got errors during the Gradle refresh.

    I would be happy to show you details. Please let me know which one you want to see.



  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    When using Spring Boot 3.1.5 and configured with flyway-code 10.0.0 (and no flyway-database-oracle dependency), the gradle refresh work, but when I try to start the application, it shows:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: Unsupported Database: Oracle 12.2<br>...<br>Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: Unsupported Database: Oracle 12.2<br>...<br>





  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    When I add in the dependency for flyway-database-oracle 10.0.0, the gradle refresh is successful, but upon application launch I get the following:

    ***************************
    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.configureProperties(FlywayAutoConfiguration.java:254)

    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/Mark.Hansen/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/3.1.5/42a5b2ee98f700fba8d8c88d4af7b23266f1de0f/spring-boot-autoconfigure-3.1.5.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/Mark.Hansen/.gradle/caches/modules-2/files-2.1/org.flywaydb/flyway-core/10.0.0/68984a8022f0daf4220a2e1605547684bea1e193/flyway-core-10.0.0.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/Mark.Hansen/.gradle/caches/modules-2/files-2.1/org.flywaydb/flyway-core/10.0.0/68984a8022f0daf4220a2e1605547684bea1e193/flyway-core-10.0.0.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


  • Options
    Apologies to keep you waiting MarkEHansen, I think the issue is the mismatch between Flyway and Spring versions.

    I believe it you update Spring to 3.1.6, the config issue should be resolved based off
    https://github.com/spring-projects/spring-boot/issues/38164
    &
    https://github.com/spring-projects/spring-boot/issues/38267
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    Upgrading to Spring Boot 3.1.6 resolved the compatibility issue. However when I launch my Java Spring Boot application pointing to an Oracle 12.2 database, I see two issues:

    First, is the following message is written to the console log:

    Oracle 12.2 is outside of Redgate community support. See https://rd.gt/468B6ni for details

    It does create the history table in the database, but then the initial migration record is not created in that database. I see these messages:

    Creating Schema History table "XT"."FLYWAY_SCHEMA_HISTORY" with baseline ...
    Successfully baselined schema with version: 1

    But when I inspect that table, there are no records. I don't have any migrations yet, but when I run the application pointing at a later Oracle database version, the history table is created and the initial base migration record is created.

    I created a migration script and started the application again. This time, it created the history table, created the table referenced in the migration script but then got an error when trying to insert the migration record into the history table:

    SQL State  : 42000
    Error Code : 1950
    Message    : ORA-01950: no privileges on tablespace 'USERS'

    2023-11-24T05:38:34,711-08:00 [main] INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat]
    2023-11-24T05:38:34,723-08:00 [main] INFO  o.s.b.a.l.ConditionEvaluationReportLogger -

    Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
    2023-11-24T05:38:34,738-08:00 [main] ERROR o.s.boot.SpringApplication - Application run failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Unable to insert row for version '2.0' in Schema History table "XT"."FLYWAY_SCHEMA_HISTORY"

    Looking at the history table, it contains no records, not even the base migration version.

    I'm running the application with the following properties:

    spring.flyway.enabled=true
    spring.flyway.locations=classpath:/db/migration
    spring.flyway.defaultSchema=XT
    spring.flyway.table=FLYWAY_SCHEMA_HISTORY
    spring.flyway.baselineVersion=1
    spring.flyway.baselineOnMigrate=true

    spring.flyway.user=our admin user
    spring.flyway.password=our admin user's password




  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    Note that if I use a SQL client tool and attempt to insert a row into the history table as my admin user, I get the same error. Was the history table created improperly? Missing a grant or something?
  • Options
    Yes, I should clarify.

    As you can see, you're able to progress now with an older version, that's what the cited post referred to, that this functionality was now unblocked.

    The statement "Oracle 12.2 is outside of Redgate community support. See https://rd.gt/468B6ni for details" means that issues might be unsupported for that db version. General flyway issues will of course continue to be worked on. Say for example there were historic bug in older flyway versions for this older db version, our allowing the functionality is 'as is' and not intending to broaden the support scope to avoid increasing development overhead. Were the issue also present in newer versions, it would be addressed.

    As for your missing schema history table, it reads to me as though it's failing silently due to lack of tablespace to write to.

    Is your admin user meant to be using the USERS tablespace and do they have a data allocation?
    Given your comment on attempting a manual insertion with another tool, it seems as though the user doesn't have the needed rights.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    Our DBA says that the table is created in the "USERS" tablespace and should not be. I see that the history table created by the previous version was in the DBDATA tablespace, as it should be. Is the 10.0.0 version broken?
  • Options
    MarkEHansenMarkEHansen Posts: 10 New member
    I didn't have the tablespace property set - I didn't know about it. I've set it and now the application launches against the Oracle 12.2 database and is able to create the history table and insert records into it.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file