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

Dependent jars for Java migrations not on class path, same as in issue #783 #2245

Closed
Lucas3oo opened this issue Dec 19, 2018 · 7 comments
Closed

Comments

@Lucas3oo
Copy link

@Lucas3oo Lucas3oo commented Dec 19, 2018

Which version and edition of Flyway are you using?
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)

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Which database are you using (type & version)?
Which operating system are you using?
What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)

What did you expect to see?
What did you see instead?
@Lucas3oo
Copy link
Author

@Lucas3oo Lucas3oo commented Dec 19, 2018

Which version and edition of Flyway are you using?
5.2.4

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)

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

Which database are you using (type & version)?
MySQL 5.6
Which operating system are you using?
MacOS
What did you do?
I have put my Java migration into the jar database-migration.jar and put that along with Spring jdbc JARS in to the folder $workingdir/build/libs.

The I execute flyway like this:

flyway -user=root -password= -url=jdbc:mysql://127.0.0.1:3306/mydb -jarDirs=./build/libs -locations=filesystem:./sql,classpath:com/example/db/migration migrate

What did you expect to see?
I expect the migration to work

What did you see instead?

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/jdbc/core/JdbcTemplate

Running with -X

DEBUG: Loading config file: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/conf/flyway.conf
DEBUG: Unable to load config file: /Users/lpersson/flyway.conf
DEBUG: Unable to load config file: /Users/lpersson/src/database/flyway.conf
DEBUG: Using configuration:
DEBUG: flyway.jarDirs -> ./build/libs
DEBUG: flyway.password ->
DEBUG: flyway.url -> jdbc:mysql://127.0.0.1:3306/cepheid_development
DEBUG: flyway.user -> root
DEBUG: flyway.locations -> filesystem:./sql,classpath:com/cepheid/cloud/db/migration
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/derby-10.14.2.0.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/derbyclient-10.14.2.0.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/h2-1.4.197.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/hsqldb-2.4.1.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/jna-4.5.2.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/jna-platform-4.5.2.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/jtds-1.3.1.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/mariadb-java-client-2.3.0.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/mssql-jdbc-7.0.0.jre8.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/mysql-connector-java-8.0.12.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/postgresql-42.2.5.jre6.jar
DEBUG: Adding location to classpath: /usr/local/Cellar/flyway@5.2.4/5.2.4/libexec/drivers/sqlite-jdbc-3.23.1.jar
DEBUG: Adding location to classpath: ./build/libs/database-migration.jar
DEBUG: Adding location to classpath: ./build/libs/flyway-core-5.2.4.jar
DEBUG: Adding location to classpath: ./build/libs/geojson-jackson-1.8.1.jar
DEBUG: Adding location to classpath: ./build/libs/jackson-annotations-2.9.0.jar
DEBUG: Adding location to classpath: ./build/libs/jackson-core-2.9.6.jar
DEBUG: Adding location to classpath: ./build/libs/jackson-databind-2.9.6.jar
DEBUG: Adding location to classpath: ./build/libs/spring-beans-5.0.8.RELEASE.jar
DEBUG: Adding location to classpath: ./build/libs/spring-core-5.0.8.RELEASE.jar
DEBUG: Adding location to classpath: ./build/libs/spring-jcl-5.0.8.RELEASE.jar
DEBUG: Adding location to classpath: ./build/libs/spring-jdbc-5.0.8.RELEASE.jar
DEBUG: Adding location to classpath: ./build/libs/spring-tx-5.0.8.RELEASE.jar
Flyway Community Edition 5.2.4 by Boxfuse

@Lucas3oo
Copy link
Author

@Lucas3oo Lucas3oo commented Dec 19, 2018

I suppose I can make a "fat"/"uber" JAR with all the third party class into the same JAR as my Java migration but I consider that a hack.

@Lucas3oo
Copy link
Author

@Lucas3oo Lucas3oo commented Dec 19, 2018

Seems like the fix for #783 got removed at some later commit.

@axelfontaine axelfontaine added this to the Flyway 6.0.0 milestone Jan 4, 2019
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Apr 11, 2019
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Apr 11, 2019

Good catch. This broke as part of the fixes for Java 9. This classloader structure has now once again been flattened to have just one new URLClassLoader which includes all additional jars and has the ContextClassLoader as a parent.

@Lucas3oo
Copy link
Author

@Lucas3oo Lucas3oo commented Apr 13, 2019

thanks :-)

@bechhansen
Copy link

@bechhansen bechhansen commented May 4, 2019

I have the same issue when trying to use Jackson from my Java migrator.

From debug:

...
DEBUG: Adding location to classpath: /flyway/jars/jackson-annotations-2.9.8.jar
DEBUG: Adding location to classpath: /flyway/jars/jackson-databind-2.9.8.jar
DEBUG: Adding location to classpath: /flyway/jars/jackson-core-2.9.8.jar
...
The DEBUG output says that the jars are found but I get the following error:
DEBUG: Skipping db.migration.xxxxxxxx (NoClassDefFoundError: com/fasterxml/jackson/core/JsonFactory caused by ClassNotFoundException: com.fasterxml.jackson.core.JsonFactory at java.net.URLClassLoader.findClass:381

I have tried this for both 5.2.4 and 6.0.0-beta.
Are you sure the issue is fixed or is it just not in 6.0.0-beta yet?

Can we maybe do a 5.2.5 or 6.0.0-beta2 containing the fix?

@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented May 6, 2019

@bechhansen In which directory did you place your migrations jar?

@axelfontaine axelfontaine removed this from the Flyway 6.0.0 milestone May 22, 2019
@axelfontaine axelfontaine added this to the Flyway 6.0.0-beta2 milestone May 22, 2019
dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants