【发布时间】:2022-12-16 05:26:05
【问题描述】:
我们有一个带有 Flyway 8.5.13(Postgresql 驱动程序 42.2.9)、Java 11.0.17 的 Spring Boot (2.6.7) 应用程序
昨天我们将 tomcat 从版本 9.0.69 更新到 9.0.70,现在应用程序无法启动。 相关日志如下所示:
Caused by: java.lang.NullPointerException
at org.flywaydb.core.internal.resource.classpath.ClassPathResource.read(ClassPathResource.java:108)
at org.flywaydb.core.internal.resolver.ChecksumCalculator.calculateChecksumForResource(ChecksumCalculator.java:64)
at org.flywaydb.core.internal.resolver.ChecksumCalculator.calculate(ChecksumCalculator.java:43)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.getChecksumForLoadableResource(SqlMigrationResolver.java:127)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.addMigrations(SqlMigrationResolver.java:169)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:71)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:50)
奇怪的是,org.flywaydb.core.internal.scanner.classpath.ClassPathScanner和org.flywaydb.core.internal.resource.ResourceNameValidator事先正确识别了迁移文件
出现异常的源代码(org.flywaydb.core.internal.resource.classpath.ClassPathResource.read(ClassPathResource.java:108))如下所示:
InputStream inputStream = null;
try {
Enumeration<URL> urls = classLoader.getResources(fileNameWithAbsolutePath);
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url.getPath() != null && url.getPath().contains(parentURL)) {
inputStream = url.openStream();
break;
}
}
} catch (IOException e) {
throw new FlywayException(e);
}
if (inputStream == null) {
throw new FlywayException("Unable to obtain inputstream for resource: " + fileNameWithAbsolutePath);
}
任何想法可能是什么原因?
我试了几个8.5版本的Flyway都没有区别!
【问题讨论】:
标签: postgresql spring-boot tomcat flyway