Apache POI 写入 Excel 在 Eclipse 中有效,但在 OpenJDK 11 中编译为 Jar 后无效

Apache POI Write to Excel Works in Eclipse but not after compiling to Jar in OpenJDK 11

我有一个项目涉及使用 Apache POI XSSFWorkbook() class.

写入 Excel 电子表格 (.xlsx)

它在以前版本的 Apache POI 中运行良好 Java 8。最近我们将代码库迁移到 OpenJDK 11,并将 Apache POI 的 Maven 版本更新到 4.1.0,如常见问题解答中指定 Apache POI FAQ.

在 Eclipse 本身中,它能够按预期为我的桌面生成 excel 工作表(在 Win 7 机器上)。但是做了maven打包成jar文件后,jar版本不行

我是不是编译错了? 下面的代码片段(不包含所有 classes,因为还有一堆其他 classes 从不同来源读取数据)

private Workbook getWorkbook(String excelFilePath)
        throws IOException, EncryptedDocumentException, InvalidFormatException {
    Workbook workbook = null;

    if (excelFilePath.endsWith("xlsx")) {
        workbook = new XSSFWorkbook();
    //} else if (excelFilePath.endsWith("xls")) {
        //workbook = new HSSFWorkbook();
    } else {
        throw new IllegalArgumentException("The specified file is not Excel file");
    }

    return workbook;
}

public void writeReport(String excelFilePath) throws Exception {
    workbook = getWorkbook(excelFilePath);
    createHelper = workbook.getCreationHelper();

    //Summary Sheet
    TCOTSummarySheet summarySheet = new TCOTSummarySheet(workbook);
    summarySheet.setProject(PROJECT);
    summarySheet.setMaps(headerInfo, reportInfo, queryLinks);
    summarySheet.createSheet();

    //Bug Breakdown Sheet
    if (bugBreakdownFlag) {
        TCOTBugBreakdownSheet bugBreakdownSheet = new TCOTBugBreakdownSheet(workbook);
        bugBreakdownSheet.setSummarySheet(summarySheet);
        bugBreakdownSheet.setMaps(headerInfo, reportInfo, queryLinks);
        bugBreakdownSheet.createSheet();
    }


    //Complete Write
    try (FileOutputStream outputStream = new FileOutputStream(excelFilePath)) {
        workbook.write(outputStream);
    }
    catch (Exception e) {
        System.out.println(e.getLocalizedMessage());
    }
    workbook.close();
}

编辑:

为了向总体项目提供更多上下文,它是一个用 OpenJDK 11 编写的 JavaFX 项目。

此特定部分涉及 运行 从 JavaFX 执行的 Swing 应用程序。这个 Swing 应用程序实际上是使用 Apache POI 生成 Excel 报告的应用程序。这可能是线程问题造成的吗?

编辑 2: 添加了堆栈跟踪的图片

编辑 3: 我尝试将 javax 依赖项添加到我的 pom.xml 中,还尝试将它们添加为引用的外部库,但无济于事。

<!-- JAXB/Javax Dependencies -->
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.4.0-b180830.0359</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/javax.activation-api -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>javax.activation-api</artifactId>
        <version>1.2.0</version>
    </dependency>

我一直在用maven包编译。

问题是自定义运行时图像不包含 jdk.charsets

jdk.charsets 在使用 jlink 应用程序创建 apache poi 使​​用的运行时时需要包含。