在 Linux (Servicemix) 下运行时,在工作表上调用 autoSizeColumn 时发生崩溃

发布于 2024-12-04 08:56:37 字数 376 浏览 2 评论 0原文

我编写了生成Excel的模块,并在ServiceMix下部署了它。在Windows环境中,一切都很好,但是在Linux ServiceMix下,会出乎意料地崩溃:

    for (short i=0;i<=3;i++) {
        log.trace("AutoSize column {}", i);
        worksheet.autoSizeColumn(i);
    }

我使用POI版本4.2-Final,FuseesB 4.2,Java 5.0。但是,没有HS_ERR*.pid文件。 ServiceMix日志在第一个AutoSizecolumn呼叫上结束。

有没有人遇到这种行为并知道它是如何引起的以及如何解决的?

I've written module that generates excel, and deployed it under Servicemix. In Windows environment everything is fine, but under Linux Servicemix unexpectedly crashes on following call:

    for (short i=0;i<=3;i++) {
        log.trace("AutoSize column {}", i);
        worksheet.autoSizeColumn(i);
    }

I'm using POI version 4.2-FINAL, FuseESB 4.2, Java 5.0. There are, however, no hs_err*.pid files. Servicemix logs ends on first autoSizeColumn call.

Did anyone met such behaviour and know, how it is caused and how to come this around?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

绻影浮沉 2024-12-11 08:56:38

为了能够计算列宽度,POI需要保留使用中的字体,并要求它依次尺寸每个字符。在我所知道的所有JVM上,这都需要一个图形环境,因为实际工作由JVM委派给基础图形系统。

如果您在Windows上,您始终拥有一个图形系统,所以很好。在Linux上,如果您在服务器上的命令行上运行,则可能不会。 (虽然Linux作为台式机很好)

如果您在没有X服务器运行的Linux服务器上运行,则需要告诉Java运行“无头”。从 poi自动化文档

计算列宽度表。AutoSizeColumn使用Java2d类,如果没有图形环境,则将异常。如果没有图形环境,则必须告诉Java您正在以无头模式运行并设置以下系统属性:
java.awt.headless = true

尝试设置启动JVM时,我的预感会解决您的问题(这很可能是由Java引起的,找不到完整的图形环境)

In order to be able to calculate the column widths, POI needs to get hold of the Font in use, and ask it to size each character in turn. On all JVMs that I know of, this requires a graphical environment, because the actual work is delegated by the JVM to the underlying graphical system.

If you're on Windows, you always have a graphical system so that's fine. On Linux, if you're running on the command line on a server, you may not. (Linux as a desktop is fine though)

If you are running on a linux server without an X server running, you'll need to tell Java to run "headless". As taken from the POI AutoSize documentation

To calculate column width Sheet.autoSizeColumn uses Java2D classes that throw exception if graphical environment is not available. In case if graphical environment is not available, you must tell Java that you are running in headless mode and set the following system property:
java.awt.headless=true

Try setting that when you start your JVM, and I've a hunch it'll fix your issue (which is most likely caused by Java not finding a complete graphical environment)

我不会写诗 2024-12-11 08:56:38

我们尚未测试它,因为它尚未发布,但自 POI 5.2.3 以来,有一个布尔系统属性可以提供帮助:org.apache.poi.ss.ignoreMissingFontSystem

指示 Apache POI 忽略由于缺少字体和
因此即使没有字体也可以执行更多功能
安装。注意:某些功能仍然无法实现,因为
不能使用默认值,例如渲染幻灯片、绘图...

We haven't tested it as it's not released yet, but since POI 5.2.3 there's a boolean system property that could help: org.apache.poi.ss.ignoreMissingFontSystem

Instructs Apache POI to ignore some errors due to missing fonts and
thus allows to perform more functionality even when no fonts are
installed. Note: Some functionality will still not be possible as it
cannot use default-values, e.g. rendering slides, drawing, ...

你对谁都笑 2024-12-11 08:56:38

嗨,我遇到了类似的问题。我没有发生任何崩溃,但在我的开发环境(Windows)上,autosizecolumn 起作用了。在生产环境(类Unix)上它不起作用。我设置了系统属性 java.awt.headless=true 但问题仍然存在。我解决了以下 这个解决方案,但我添加了所有 Arial Family 字体。希望它对任何人都有帮助。

Hi I faced a similar problem. I didn't have any crash, but on my development environment (Windows) the autosizecolumn worked. On production environment (Unix-like) it didn't work. I put system property java.awt.headless=true but I had the problem still. I solved following this solution but I added all the Arial Family fonts. Hope it helps anyone.

自由如风 2024-12-11 08:56:38

我在迁移服务器(OpenJDK 1.8、Rocky Linux 9)时遇到了同样的问题,

无头设置对我没有帮助(java.awt.headless=true)。但安装 fontconfig 解决了这个问题。我假设这个包带有默认字体。

gt; sudo dnf install fontconfig
gt; fc-list

I faced the same issue while migrating servers (OpenJDK 1.8, Rocky Linux 9)

The headless settings didn't help me (java.awt.headless=true). But installing fontconfig solved the problem. I assume this package is coming with default fonts.

gt; sudo dnf install fontconfig
gt; fc-list
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文