Tariq Islam
Tariq Islam

Reputation: 13

Flyway unable to scan for sql migrations in class path after upgrade to tomcat 8

Our application have been working fine with flyway 3.0 and tomcat 7. We are using sql based migrations in class path.

Recently we are trying to upgrade our application to use tomcat 8. After doing so, flyway was unable to find sql migrations in our class path. We have been using WAR deployment with unpackWAR = false. For the information only, using unpackWAR = true, the problem no longer is reproducible.

I have tried to debug into flyway code base some what and have been trying to figure out the differences prior to upgrading to tomcat 8 and after upgrading to tomcat 8. One key difference that I found is that inside ClassPathScanner.getLocationUrlsForPath(), previously we used to find the location of the WAR file prefixed with file: protocol, however now with tomcat 8, we are finding the location of the WAR file prefixed with jar: protocol. This doesn't seem very problematic. However, this leads to code inside JarFileClassPathLocationScanner.findResourceNamesFromJarFile() being executed. Inside this method, jar elements entry names come out to be something like "WEB-INF/classes/our_path/schema/V1.0.sql", etc however the location specified is only our_path/schema/V1.0.sql. Since there's the condition,

if(entryName.startsWith(location)) {

our schema migrations are not being picked up.

Any thoughts? Does this sound like a bug?

Upvotes: 1

Views: 388

Answers (1)

Axel Fontaine
Axel Fontaine

Reputation: 35189

This should work out of the box. Please file an issue in the issue tracker with the steps to reproduce (or even better a small repro repo).

Upvotes: 1

Related Questions