Issue 239 in flyway: Flyway 1.6 classpath scanner does not find files unless baseDir has trailing '/'

1,454 views
Skip to first unread message

fly...@googlecode.com

unread,
Apr 10, 2012, 12:44:28 AM4/10/12
to flywa...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 239 by tarkast...@gmail.com: Flyway 1.6 classpath scanner does
not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hi,

If I initialise Flyway in Spring as follows:

<bean id="flywayMigration" class="com.googlecode.flyway.core.Flyway"
init-method="migrate">
<property name="dataSource" ref="xaDataSource"/>
<property name="baseDir" value="migrations"/>
</bean>

This will fail to find any migrations under '<classpath>/migrations/...'.
However appending '/' to the baseDir fixes this. This previously worked in
1.5.

This appears to be due to line 195 of ClassPathScanner.java:

String resourceName = scanRootLocation +
normalizedPath.substring(scanRoot.length());

The scanner should check if scanRootLocation is terminated by an
appropriate separator.


fly...@googlecode.com

unread,
Apr 10, 2012, 2:06:59 PM4/10/12
to flywa...@googlegroups.com

Comment #1 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6
classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hi Steve!

Thanks for reporting this! I've tried to reproduce it, but couldn't.

Could you post some more details about the directory and file layout that
must be scanned, as well as the OS you're using?

Cheers,
Axel

fly...@googlecode.com

unread,
Apr 10, 2012, 3:06:23 PM4/10/12
to flywa...@googlegroups.com

Comment #2 on issue 239 by KrisMul...@gmail.com: Flyway 1.6 classpath
scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Axel, I believe he may be refering to a change in behavior pre-spring
removal,

For example, previously this in the configuration file would work:

flyway.baseDir=sql/applicationname (where application name is a subfolder
of sql)

however, it now expects

flyway.baseDir=applicationname


fly...@googlecode.com

unread,
Apr 10, 2012, 3:40:29 PM4/10/12
to flywa...@googlegroups.com

Comment #3 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6
classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hi Kris,

this surprises me, as all test cases (including many that have a baseDir in
the form of dir/subDir) have continued to pass without changes.

Which behavior are you seeing exactly?

Let's get to the bottom of this. I'll then release a 1.6.1 to fix any
regressions.

Thanks
Axel

fly...@googlecode.com

unread,
Apr 13, 2012, 12:11:31 AM4/13/12
to flywa...@googlegroups.com

Comment #4 on issue 239 by KrisMul...@gmail.com: Flyway 1.6 classpath
scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

I'll try and find the exact configs when i'm in the office tommorow, but I
think this guy in issue 241 is having the same problem
http://code.google.com/p/flyway/issues/detail?id=241&sort=-id&colspec=ID%20Type%20Status%20Priority%20Milestone%20Reporter%20Summary%20Stars

fly...@googlecode.com

unread,
Apr 13, 2012, 12:48:56 PM4/13/12
to flywa...@googlegroups.com

Comment #5 on issue 239 by zpal...@gmail.com: Flyway 1.6 classpath scanner
does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hello, I am seeing the same issue. For me, it appears to have to do with
whether the migrations are being loaded out of a jar file as opposed to
directly from the file system. Even the default baseDir does not appear to
work for me if loading from the filesystem. To fix this, I can add the
trailing '/' character as mentioned above, but then the same migrations are
not picked up when loading out of a jar file.

fly...@googlecode.com

unread,
Apr 13, 2012, 3:35:50 PM4/13/12
to flywa...@googlegroups.com

Comment #6 on issue 239 by KrisMul...@gmail.com: Flyway 1.6 classpath
scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

axel, I think at least in the command line case, it's because :sql was
added to the classpath in flyway.sh, perviously you had to specify sql/

$JAVA_CMD -jar bin/${project.artifactId}-${project.version}.jar $@

vs

$JAVA_CMD -cp
bin/flyway-commandline-${project.version}.jar:bin/flyway-core-${project.version}.jar:bin/spring-jdbc-2.5.6.jar:bin/commons-logging-1.1.1.jar:bin/spring-beans-2.5.6.jar:bin/spring-core-2.5.6.jar:bin/spring-context-2.5.6.jar:bin/aopalliance-1.0.jar:bin/spring-tx-2.5.6.jar;bin/log4j-1.2.16.jar:sql
com.googlecode.flyway.commandline.Main $@

fly...@googlecode.com

unread,
Apr 13, 2012, 3:50:02 PM4/13/12
to flywa...@googlegroups.com

Comment #7 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6
classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hi guys,

thanks for looking into this.

@Chris: I believe Steve is using the API not the command-line tool.

As I wrote in issue 242, this behavior currently puzzles me. Can anyone
reproduce any of this in a testcase? I am currently unable to do it. All
cases I add seem to pass immediately on Windows and Ubuntu. :-/

Any help appreciated.

Cheers
Axel

fly...@googlecode.com

unread,
Apr 14, 2012, 6:41:04 PM4/14/12
to flywa...@googlegroups.com

Comment #8 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6
classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

I've attached a new build with some changes to the ClassPathScanner. Could
you tell me if it solves your problems?

Attachments:
flyway-core-1.7-SNAPSHOT.jar 142 KB

fly...@googlecode.com

unread,
Apr 20, 2012, 9:31:55 PM4/20/12
to flywa...@googlegroups.com

Comment #9 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6
classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

@tarkasteve Any news? Does the new jar work for you?

fly...@googlecode.com

unread,
Apr 22, 2012, 6:46:30 PM4/22/12
to flywa...@googlegroups.com

Comment #10 on issue 239 by tarkast...@gmail.com: Flyway 1.6 classpath
scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

Hi Axel,

Yep, the attached jar fixes the issue for me.

Sorry for the delay, last week got a bit crazy.

Cheers,
Steve

fly...@googlecode.com

unread,
Apr 22, 2012, 9:22:34 PM4/22/12
to flywa...@googlegroups.com
Updates:
Status: Fixed

Comment #11 on issue 239 by axel.fontai...@gmail.com: Flyway 1.6

classpath scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

(No comment was entered for this change.)

fly...@googlecode.com

unread,
Jun 12, 2012, 11:04:25 AM6/12/12
to flywa...@googlegroups.com

Comment #12 on issue 239 by rostrzy...@gmail.com: Flyway 1.6 classpath
scanner does not find files unless baseDir has trailing '/'
http://code.google.com/p/flyway/issues/detail?id=239

I have the same problem:

Maven 2.2,1, jenkins 1.468, Linux OS

Stacktrace:

[INFO] [flyway:migrate {execution: default-cli}]
[DEBUG] Scanning URL:
file:/var/lib/jenkins/jobs/proj-core/workspace/nil-core/nil-admdb/target/classes/db/migration
[DEBUG] Scanning starting at classpath root in filesystem:
/var/lib/jenkins/jobs/proj-core/workspace/nil-core/nil-admdb/target/classes/
[DEBUG] Scanning for resources in path:
/var/lib/jenkins/jobs/proj-core/workspace/nil-core/nil-admdb/target/classes/db/migration
(classpath location: db/migration)
[DEBUG] Found resource: gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_0_0_0_20110609_A__LOGGER_AUDIT_event_dateV_MSSQL_7_0_0_0_2011_06_09_A__LOGGER_AUDIT_event_date.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20101005__DDL_adm_createV_MSSQL_7_1_0_0_2010_10_05__DDL_adm_create.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110123_A__DDL_adm_alterV_MSSQL_7_1_0_0_2011_01_23_A__DDL_adm_alter.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110123_B__DDL_adm_view_alterV_MSSQL_7_1_0_0_2011_01_23_B__DDL_adm_view_alter.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110123_C__DDL_adm_view_alter0V_MSSQL_7_1_0_0_2011_01_23_C__DDL_adm_view_alter0.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110123_D__DDL_adm_view_alter1V_MSSQL_7_1_0_0_2011_01_23_D__DDL_adm_view_alter1.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110415_A__DDL-adm-changetracerV_MSSQL_7_1_0_0_2011_04_15_A__DDL-adm-changetracer.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110415_B__DDL-adm-vxmlobjexttestV_MSSQL_7_1_0_0_2011_04_15_B__DDL-adm-vxmlobjexttest.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110420_A__DDL-adm-changetracerV_MSSQL_7_1_0_0_2011_04_20_A__DDL-adm-changetracer.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110517_A__accessRulesV_MSSQL_7_1_0_0_2011_05_17_A__accessRules.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110518_A__accessRulesV_MSSQL_7_1_0_0_2011_05_18_A__accessRules.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110519_A__Alter-ANILKeyRulesV_MSSQL_7_1_0_0_2011_05_19_A__Alter-ANILKeyRules.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20110520_A__accessRulesV_MSSQL_7_1_0_0_2011_05_20_A__accessRules.sql
[DEBUG] Found resource:
gration/V_MSSQL_7_1_0_0_20120321_A__menuV_MSSQL_7_1_0_0_2012_03_21_A__menu.sql
[ERROR] com.googlecode.flyway.core.exception.FlywayException: Unable to
obtain inputstream for resource:
gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql
[JENKINS] Archiving [...SECRET...]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Flyway Error: com.googlecode.flyway.core.exception.FlywayException:
Unable to obtain inputstream for resource:
gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql

[INFO]
------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Flyway Error:
com.googlecode.flyway.core.exception.FlywayException: Unable to obtain
inputstream for resource: gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at
org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(LifecycleExecutorInterceptor.java:65)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at hudson.maven.agent.Main.launch(Main.java:185)
at hudson.maven.MavenBuilder.call(MavenBuilder.java:151)
at hudson.maven.Maven2Builder.call(Maven2Builder.java:77)
at hudson.maven.Maven2Builder.call(Maven2Builder.java:53)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:287)
at
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.apache.maven.plugin.MojoExecutionException: Flyway Error:
com.googlecode.flyway.core.exception.FlywayException: Unable to obtain
inputstream for resource: gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql
at
com.googlecode.flyway.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:166)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at
hudson.maven.agent.PluginManagerInterceptor.executeMojo(PluginManagerInterceptor.java:182)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 28 more
Caused by: com.googlecode.flyway.core.exception.FlywayException: Unable to
obtain inputstream for resource:
gration/V_MSSQL_7_0_0_0_005__LOGGER_AUDIT.sql
at
com.googlecode.flyway.core.util.ClassPathResource.loadAsString(ClassPathResource.java:86)
at
com.googlecode.flyway.core.migration.sql.SqlMigration.<init>(SqlMigration.java:67)
at
com.googlecode.flyway.core.migration.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:107)
at
com.googlecode.flyway.core.migration.MigrationProvider.collectMigrations(MigrationProvider.java:150)
at
com.googlecode.flyway.core.migration.MigrationProvider.doFindAvailableMigrations(MigrationProvider.java:131)
at
com.googlecode.flyway.core.migration.MigrationProvider.findAvailableMigrations(MigrationProvider.java:110)
at com.googlecode.flyway.maven.MigrateMojo.doExecute(MigrateMojo.java:155)
at
com.googlecode.flyway.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:158)
... 31 more


Reply all
Reply to author
Forward
0 new messages