我正在使用Java + OpenOffice开发Web应用程序来生成报告文档。
在Fedora计算机上安装了tomcat服务器和war文件。
下面的代码可以在Windows操作系统上创建编写器文档,但在使用war文件从客户端调用时会在Fedora机器上出错:
String oooExeFolder = "/usr/lib/openoffice.org3/program";
XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
XComponent xcomp = xcomponentloader.loadComponentFromURL(filep[i], "_blank", 0, new PropertyValue[0]);
这是错误:
CE> /usr/lib/openoffice.org3/program/soffice.bin X11 error: Can't open display:
CE> Set DISPLAY environment variable, use -display option
CE> or check permissions of your X-Server
CE> (See "man X" resp. "man xhost" for details)
任何人都可以帮助确定此问题的可能原因吗?
答案 0 :(得分:1)
您需要以“无头”模式启动soffice
。我建议您查看JODReports或Docmosis,因为它们可以为您节省大量时间来解决此类设置问题。请注意我为创建Docmosis的公司工作。
答案 1 :(得分:0)
After Setting display to "1.0" with following code manually problem has been resolved and i am able to access Open Office from web application to generate report
oooExeFolder = "/usr/lib/openoffice.org3/program/";
List<String> oooOptions = OOoServer.getDefaultOOoOptions();
oooOptions.add("-display");
oooOptions.add(":1.0");
OOoServer server = new OOoServer(oooExeFolder, oooOptions);
XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);