我真的希望以下内容能在我们没有想法时敲响警钟。关于如何进一步诊断的答案或建议将不胜感激。
我们有一个 Java 应用程序,它已经运行了 18 个月没有问题。它现在正在迁移到运行 Windows Server 2019 Standard 作为 VM 的新平台。第一次安装时,一切正常,但应用程序会定期启动失败,只能通过重新复制所有 jar 文件来修复。这是暂时的,因为最终它再次失败。
经过大量监控,我们注意到有一个 Windows 进程会定期在所有文件上设置“L”文件属性并创建重新解析数据。这应该不是问题,但是一旦发生这种情况,JVM 将无法启动应用程序。(任何 Windows 高手都知道这是做什么的?)
一个关键点是应用程序是通过指定 JPMS 参数来启动的,例如:
java -p MyApp.jar;MyApp_mods -m mymodule/mypackage.StartGUI
Run Code Online (Sandbox Code Playgroud)
这运行良好,在 jar 文件上设置了“L”属性,然后失败并显示消息:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module format not recognized: MyApp.jar
Run Code Online (Sandbox Code Playgroud)
将 MyApp.jar 重命名为其他名称,然后将其复制回 MyApp.jar 可以解决问题,因为它会创建一个没有 L 属性和重新解析数据的文件(直到进程重新应用它)
此行为不仅适用于这一操作,还适用于使用模块系统的任何地方,例如:
java --list-modules any-jar-in-the-app.jar
Run Code Online (Sandbox Code Playgroud)
有趣的是(!),如果我们尝试一个更简单的非模块化应用程序并运行:
java -jar MySimpleApp.jar
Run Code Online (Sandbox Code Playgroud)
那么即使设置了 L 属性,应用程序也能正常运行。
显然我们并不完全理解,但看起来好像通过模块系统运行以某种方式意味着无法读取具有 L 属性/重新解析数据的文件(?)
我们已经尝试了各种版本的 OpenJDK 热点和 OpenJ9 JVM,但结果相同。有任何想法吗?
我正在使用 Apache POI 3.17 阅读 Excel 2013 工作簿。工作簿由用户直接在 Excel 中创建和编辑。然后我运行一个 Java 8 程序,该程序使用 POI 来读取和处理工作簿。
有些单元格是颜色编码的,所以我需要获取填充颜色。在许多情况下,这工作正常,但有一组灰色/银色不起作用,我不确定为什么。
例如,Excel 单元格如下所示:
我获取填充颜色的代码是:
private String getFillColor(XSSFCell cell) {
String fColorString = "None";
if (cell != null) {
XSSFCellStyle cellStyle = cell.getCellStyle();
short sColorFore = cellStyle.getFillForegroundColor();
short sColorBack = cellStyle.getFillBackgroundColor();
XSSFColor xColorFore = cellStyle.getFillForegroundColorColor();
XSSFColor xColorBack = cellStyle.getFillBackgroundColorColor();
String s = "";
s += " indexFore=" + sColorFore;
s += " indexBack=" + sColorBack;
s += " colorFore=" + ((xColorFore == null) ? "Null" : …Run Code Online (Sandbox Code Playgroud)