I have dug a bit more on this I have dug a bit more on this - my original checking code was wrong The problem (I think) is that the J2E classloader doesn't seem to recognise a "folder" as a resource. String checkFile = "database_migration/V1__my_db.sql"; // specific SQL fileSystem.out.println("Datafile ["+checkFile+"]");URL resource = Thread.currentThread().getContextClassLoader().getResource(checkFile);if (resource != null) { System.out.println("RESOURCE FILE ["+checkFile+"] URL["+resource.toExternalForm()+"]"); }else { System.out.println("RESOURCE URL returned ["+(resource != null ? resource.toString() : "is null")+"]"); } Returns (I note the j2e: reference in URL) RESOURCE FILE [database_migration/V1__my_db.sql] URL[j2e:libs/MyDBUtiliity.jar!database_migration/V1__my_db.sql] However with just a folder as String checkFile = "database_migration"; // just folder with versioned SQL files Returns RESOURCE URL returned [is null] Whereas in normal java environment this returns RESOURCE FILE [database_migration] URL[file:/C:/Users/david/dev/MyApplication/target/classes/database_migration] My problem is that Flyway seems to only work at folder level Flyway flyway = new Flyway();flyway.setClassLoader(Thread.currentThread().getContextClassLoader());flyway.setDataSource(ds);flyway.setLocations(migrations); // String[] with multiple folders with versioned SQL filesflyway.setCallbacks(new MyFlywayCallback());flyway.migrate(); I'm looking for a work-around in Flyway - but wondered if you could confirm J2E ClassLoader support for folders as resource? Edit: Flyway is a BoxFuse product (rather than Google as I indicated above) - here is their info on Database Migrations <https://flywaydb.org/documentation/migrations#versioned-migrations>. I have got the option to use "filesystem:" working - rather than "classpath:", but that would leave SQL files, which define the application database, exposed and getting the classpath approach working is my strong preference. Thanks David reply
I have dug a bit more on this - my original checking code was wrong
The problem (I think) is that the J2E classloader doesn't seem to recognise a "folder" as a resource.
String checkFile = "database_migration/V1__my_db.sql"; // specific SQL file
System.out.println("Datafile ["+checkFile+"]");
URL resource = Thread.currentThread().getContextClassLoader().getResource(checkFile);
if (resource != null) {
System.out.println("RESOURCE FILE ["+checkFile+"] URL["+resource.toExternalForm()+"]");
}
else {
System.out.println("RESOURCE URL returned ["+(resource != null ? resource.toString() : "is null")+"]");
}
Returns (I note the j2e: reference in URL)
RESOURCE FILE [database_migration/V1__my_db.sql] URL[j2e:libs/MyDBUtiliity.jar!database_migration/V1__my_db.sql]
However with just a folder as
String checkFile = "database_migration"; // just folder with versioned SQL files
Returns
RESOURCE URL returned [is null]
Whereas in normal java environment this returns
RESOURCE FILE [database_migration] URL[file:/C:/Users/david/dev/MyApplication/target/classes/database_migration]
My problem is that Flyway seems to only work at folder level
Flyway flyway = new Flyway();
flyway.setClassLoader(Thread.currentThread().getContextClassLoader());
flyway.setDataSource(ds);
flyway.setLocations(migrations); // String[] with multiple folders with versioned SQL files
flyway.setCallbacks(new MyFlywayCallback());
flyway.migrate();
I'm looking for a work-around in Flyway - but wondered if you could confirm J2E ClassLoader support for folders as resource?
Edit:
Flyway is a BoxFuse product (rather than Google as I indicated above) - here is their info on Database Migrations <https://flywaydb.org/documentation/migrations#versioned-migrations>.
I have got the option to use "filesystem:" working - rather than "classpath:", but that would leave SQL files, which define the application database, exposed and getting the classpath approach working is my strong preference.
Thanks
David