【问题标题】:ClassLoader NullPointerException with Flyway 8.5.13 and Tomcat 9.0.70 - works with Tomcat 9.0.69Flyway 8.5.13 和 Tomcat 9.0.70 的 ClassLoader NullPointerException - 适用于 Tomcat 9.0.69
【发布时间】: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.ClassPathScannerorg.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


    【解决方案1】:

    您可能偶然发现了错误 BZ 66388,最近已修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 2018-08-26
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多