classpath - Flyway not finding the migrations in a jar file -


i implemented flyway in number of applications support , worked dream.

however deployed applications test environment migrations stopped working.

after investigation found migrations not being located flyway when loaded jar file, when not zipped (like when working in eclipse or if extract jar classpath) works expected.

due plugin architecture of applications not in position use "default" setting , such setting flyway object this:

flyway flyway = new flyway(); flyway.setdatasource(datasource); flyway.setbasedir("za/co/company/application/plugin1/db/migration"); flyway.settable(tablename); flyway.setbasepackage("za.co.company.application.plugin1.db.migration"); flyway.init(); flyway.migrate(); 

if 1 unzip jar file sql files located in: za/co/company/application/db/migration

as mentioned know migrations work, not when in jar file. code above executes perfectly, it's there no sql files found run part of migration.

although originaly developed using flyway-core-1.6 have tried (with same negative results) 1.6.1 , 1.7_snapshot release found here , here similar problem reported.

edit: additional info

os: windows xp
jdk: 1.7.0_04
db: sql server 2005
running straight command window via bat file.

2012-06-27 15:50:05.855 main: flyway.migrate() 2012-06-27 15:50:05.886 database: microsoft sql server 2012-06-27 15:50:05.902 schema: dbo 2012-06-27 15:50:05.902 unable find path sql migrations: za\co\company\application\plugin1\db\migration 2012-06-27 15:50:05.918 scanning url: jar:file:/c:/temp/lib/plugin1.jar!/za/co/company/application/plugin1/db/migration 2012-06-27 15:50:05.918 filtering out resource: za/co/company/application/plugin1/db/migration/ (filename: ) 2012-06-27 15:50:05.918 filtering out resource: za/co/company/application/plugin1/db/migration/v1_1__allows_cancelations.sql (filename: v1_1__allows_cancelations.sql) 2012-06-27 15:50:05.918 filtering out resource: za/co/company/application/plugin1/db/migration/v1__base_version.sql (filename: v1__base_version.sql) 2012-06-27 15:50:05.933 main: done migrate. 

i have confirmed using default prefix (v) , suffix (.sql). , names of migration files mentioned in log being filtered out indeed migrations have performed.

edit: still more info. cloned source repository , got stack trace before resource logged being filtered out.

at com.googlecode.flyway.core.util.scanner.classpathscanner.filterresourcenames(classpathscanner.java:203) @ com.googlecode.flyway.core.util.scanner.classpathscanner.findresourcenames(classpathscanner.java:136) @ com.googlecode.flyway.core.util.scanner.classpathscanner.scanforclasses(classpathscanner.java:67) @ com.googlecode.flyway.core.migration.jdbc.jdbcmigrationresolver.resolvemigrations(jdbcmigrationresolver.java:51) @ com.googlecode.flyway.core.migration.compositemigrationresolver.collectmigrations(compositemigrationresolver.java:175) @ com.googlecode.flyway.core.migration.compositemigrationresolver.dofindavailablemigrations(compositemigrationresolver.java:156) @ com.googlecode.flyway.core.migration.compositemigrationresolver.resolvemigrations(compositemigrationresolver.java:119) @ com.googlecode.flyway.core.flyway$1.execute(flyway.java:565) @ com.googlecode.flyway.core.flyway$1.execute(flyway.java:1) @ com.googlecode.flyway.core.flyway.execute(flyway.java:850) @ com.googlecode.flyway.core.flyway.migrate(flyway.java:561) 

i have confirmed time migrations filtered out when finds them in jar file. if .sql migrations not scanned when re inside jar file.

i still poking around , update accordingly.

edit: source code query: not overly familiar flyway source code have been poking around in few hours...

what piece of code in resolvemigrations method of sqlmigrationresolver class supposed do? if remove code sqlmigrations load jar file, if not don't load , warning logged.

    if (stringutils.hastext(normalizedbasedir)) && !new classpathresource(normalizedbasedir + "/").exists() ) {         log.warn("unable find path sql migrations: " + location);         return migrations;     } 

try newly released 1.7. offending statement has been removed.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -