在崩溃调用工作表时autoSizeColumn时,在Linux下(ServiceMix的)运行 [英] Crash when calling autoSizeColumn on worksheet, when run under Linux (Servicemix)

查看:2717
本文介绍了在崩溃调用工作表时autoSizeColumn时,在Linux下(ServiceMix的)运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写模块,生成Excel和ServiceMix的部署下它。在Windows环境下,一切都很好,但在Linux下的ServiceMix意外崩溃在以下调用:

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);
    }

我使用POI 4.2版决赛,FuseESB 4.2,Java 5.0中。有,但是,没有hs_err * .pid文件。 ServiceMix的日志上第一autoSizeColumn通话结束。

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?

推荐答案

为了能够计算列宽,POI需要获得使用的字体抱起来,它要求大小每个字符反过来。在我所知道的所有JVM,这需要一个图形环境,因为实际工作是由JVM委托给底层的图形化系统。

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.

如果您使用的是Windows,你总是有一个图形化的系统,以便很好。在Linux上,如果你的服务器在命令行上运行,则可能不会。 (Linux作为桌面是罚款虽然)

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)

如果您在没有X服务器运行的是Linux服务器上运行,你需要告诉Java运行无头。在 POI自动调整大小文档获取

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

要计算列宽Sheet.autoSizeColumn使用抛出异常,如果图形环境不可用的Java2D类。如果在图形环境中不可用的情况下,你必须告诉你是在无头的模式下运行的Java,并设置下面的系统属性:
   java.awt.headless = TRUE

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

尝试设置,当你开始你的JVM,我已经预感​​这将解决您的问题(这是最有可能被Java造成没有找到一个完整的图形化环境)

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)

这篇关于在崩溃调用工作表时autoSizeColumn时,在Linux下(ServiceMix的)运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆