Location not found on flyway migrate on websphere

一笑奈何 提交于 2021-02-07 19:15:30

问题


I'm trying to setup flyway-migration on Websphere server.

My project consists of the modules:

 --projectwar.war
     --projectsql.jar
          --java
              --MyFlywayUtil.class
          -- resources
               -- myscripts
     --projectmodel.jar
           --java
                --MyRiskDataSourceConfig.class

MyRiskDataSourceConfig contains flyway migration declaration:

@Bean(initMethod = "migrate")
public Flyway flyway(@Qualifier("myDataSource") DataSource dataSource) {
    Flyway flyway = new Flyway();
    flyway.setBaselineOnMigrate(true);
    flyway.setClassLoader(MyFlywayUtil.class.getClassLoader());
    flyway.setLocations("classpath:"+"myscripts");
    flyway.setDataSource(dataSource);
    return flyway;
}

When executed under Tomcat using bootRun comand, migration works fine and location is found.

However under Websphere I receive the following:

com.ibm.ws.classloader.CompoundClassLoader@bb6f8b91[app]
Local ClassPath 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/classes 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/lib/projectmodel.jar 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/lib/projectsql.jar 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war 

Parent com.ibm.ws.classloader.ProtectionClassLoader@c26663d6 Delegation Mode  PARENT_FIRST) 
On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!
o.f.c.i.u.s.classpath.ClassPathScanner Unable to resolve location classpath myscripts

I've tried configuration with and without flyway.setClassLoader();

Any help would be appreciated.


回答1:


Did you also add an (empty) file with the name flyway.location to the folder(s) containing your migrations, in my cases this fixed the problem.

Because of the way the IBM class-loader works this file has to be added as a workaround, see also the source

And of course the warning which is given:

On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!




回答2:


According to this git issue, the problem was fixed in flyway 4.0.1



来源:https://stackoverflow.com/questions/47775874/location-not-found-on-flyway-migrate-on-websphere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!