各位,在使用openOffice结合jodconverter 把word文件转换为html时,发现总是报异常:com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not load input document;
但是,这个问题是偶发的,偶尔传一个文件,也能正常转换,没有任何问题;
调试源码发现在
private void loadAndExport(String inputUrl, Map/*<String,Object>*/ loadProperties, String outputUrl, Map/*<String,Object>*/ storeProperties) throws OpenOfficeException {
XComponent document;
try {
document = loadDocument(inputUrl, loadProperties);
} catch (ErrorCodeIOException errorCodeIOException) {
throw new OpenOfficeException("conversion failed: could not load input document; OOo errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
} catch (Exception otherException) {
throw new OpenOfficeException("conversion failed: could not load input document", otherException);
}
if (document == null) {
throw new OpenOfficeException("conversion failed: could not load input document");
}
refreshDocument(document);
try {
storeDocument(document, outputUrl, storeProperties);
} catch (ErrorCodeIOException errorCodeIOException) {
throw new OpenOfficeException("conversion failed: could not save output document; OOo errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
} catch (Exception otherException) {
throw new OpenOfficeException("conversion failed: could not save output document", otherException);
}
}
document = loadDocument(inputUrl, loadProperties);
获得document为null,所以 throw new OpenOfficeException("conversion failed: could not load input document");
很费解为什么得到的document为null呢;
以下是本人尝试的解决途径:
1 ) I solved the problem by installing "Writer" and "Calc" components on OpenOffice.org side.
Good luck. --》 照做,没有解决问题
2 ) 配置openOffice的 environment variable : C:\Program Files\OpenOffice.org 3\program --》照做,没有解决问题
3 ) 确认openOffice服务已经启动
以上是本人的解决方案,望大家帮忙解决下,谢谢。。。