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

Add jackson-core to drivers #3888

Open
Simon-Hostettler opened this issue Apr 30, 2024 · 4 comments
Open

Add jackson-core to drivers #3888

Simon-Hostettler opened this issue Apr 30, 2024 · 4 comments

Comments

@Simon-Hostettler
Copy link

Which version and edition of Flyway are you using?

Docker Image flyway/flyway:10.11.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 this is also a problem in the 10.12.0 Docker image

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

Command-line

Which database are you using? (Type & version)

PostgreSQL 16.2

Which operating system are you using?

MacOS, The issue is OS-independent

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)

In issue #3218 it is mentioned that you can safely delete /flyway/lib/aad, which we did. We then call flyway -locations=/db/migration/shared,/db/migration/global -schemas=shared -placeholders.schema_name=shared info | tee --append $MIGRATION_LOG_PATH.

What did you expect to see?
What did you see instead?

This resulted in the error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/Versioned
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at org.flywaydb.commandline.Main.main(Main.java:110)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.Versioned
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 10 more
Error calling database from flyway. Retry in 1 seconds.
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/Versioned
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at org.flywaydb.commandline.Main.main(Main.java:110)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.Versioned
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 10 more

This is caused by the line MavenVersionChecker.checkForVersionUpdates() in org.flywaydb.commandline.Main. checkForVersionUpdates() creates an XmlMapper, which implements com.fasterxml.jackson.core.Versioned. jackson.core is however not part of the /flyway/drivers and instead depends on the jar in /flyway/lib/aad, i.e. can't be found anymore after deleting this directory. This jar should probably be added to the drivers.

@Barry-RG
Copy link
Contributor

Thank you for your issue. It seems to advice given in #3218 is out of date due to the last few years of development.
/flyway/drivers is for JDBC drivers and JDBC driver dependencies so would not be an appropriate place for this library.
Could you give an explanation as to why you require the deletion of /flyway/lib/aad?

@Simon-Hostettler
Copy link
Author

We had the same issue with sl4j-api as the original creator of the issue. We apparently deleted the entire dir to resolve this, when just deleting the jar works. I was just wondering if this is the correct place for this dependency to be located in the first place if parts of the code that are independent of azure active directory rely on it.

@Barry-RG
Copy link
Contributor

Barry-RG commented May 10, 2024

I am going to close this issue in due course as I believe your suggestion of just deleting the problematic jars rather than the directory for functionality you are not using is the better solution.

However, I will also take into note the location of jackson-core as the aad folder no longer feels like the correct location. It was originally there as aad was the only part of Flyway that required it. That is no longer the case but the dependency was not moved into the general lib folder.

@Barry-RG
Copy link
Contributor

Apologies for my poorly worded response before. I had read your previous comment and for some reason interpreted you as two different users. My apologies again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants