当前位置:网站首页>问题解决:OfficeException: failed to start and connect(一)
问题解决:OfficeException: failed to start and connect(一)
2022-07-01 06:28:00 【Going_man】
问题:OfficeException: failed to start and connect(一)
场景:重启tomcat服务后,预览系统启动不了
输出日志:启动office组件失败,请检查office组件是否可用
报错:org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
认定原因一:
1、杀死进程杀死不成功和启动软件进程互相冲突
boolean killOffice = killProcess();
if (killOffice) {
logger.warn("检测到有正在运行的office进程,已自动结束该进程");
}
try {
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setOfficeHome(officeHome);
configuration.setPortNumber(8100);
// 设置任务执行超时为25分钟
configuration.setTaskExecutionTimeout(1000 * 60 * 25L);
// 设置任务队列超时为24小时
configuration.setTaskQueueTimeout(1000 * 60 * 60 * 24L);
configuration.setMaxTasksPerProcess(1000);
officeManager = configuration.buildOfficeManager();
officeManager.start();
} catch (Exception e) {
logger.error("启动office组件失败,请检查office组件是否可用");
throw e;
}
//杀死进程核心代码
String[] cmd ={
"cmd","/c","taskkill /im soffice.bin /f"};
Process process= Runtime.getRuntime().exec(cmd);
//输出为1,可见杀死进程失败
logger.warn("killProcess:process"+process.waitFor());
解决方式一:
我将杀死soffice服务进程的代码注释,让其直接进行启动!
//boolean killOffice = killProcess();
//if (killOffice) {
// logger.warn("检测到有正在运行的office进程,已自动结束该进程");
//}
try {
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setOfficeHome(officeHome);
configuration.setPortNumber(8100);
// 设置任务执行超时为25分钟
configuration.setTaskExecutionTimeout(1000 * 60 * 25L);
// 设置任务队列超时为24小时
configuration.setTaskQueueTimeout(1000 * 60 * 60 * 24L);
configuration.setMaxTasksPerProcess(1000);
officeManager = configuration.buildOfficeManager();
officeManager.start();
} catch (Exception e) {
logger.error("启动office组件失败,请检查office组件是否可用");
throw e;
}
发现它可以成功启动!又尝试在杀死后面加了个延时!
Thread.sleep(5000);
结果也是可以启动!
结论一:
所以最终问题在于杀死进程命令执行后,不能立马执行启动命令,会导致报错。
边栏推荐
- SQL statement
- [postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
- Code power is full of quantitative learning | how to find a suitable financial announcement in the financial report
- [summary of problem thinking] Why is the register reset performed in user mode?
- Student attendance system for C language course (big homework)
- 根据输入画有向图
- 【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
- mysql数据类型学习笔记
- Redis安装到Windows系统上的详细步骤
- Comment imprimer le tableau original
猜你喜欢

谷粒商城-环境(p1-p27)
![[wechat applet] how to build a building block development?](/img/69/edb02c88b52b474a797307b96de369.jpg)
[wechat applet] how to build a building block development?

自开发软件NoiseCreater1.1版本免费试用

Application of IT service management (ITSM) in Higher Education

On siem

HCM Beginner (IV) - time

Redis安装到Windows系统上的详细步骤
![[wechat applet] to solve button, input and image components](/img/7f/a61ee2f610b2f0f9fb0b34cb960f81.jpg)
[wechat applet] to solve button, input and image components

问题:OfficeException: failed to start and connect(二)

软件工程复习
随机推荐
阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]
[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
MySQL learning
Chapitre V gestion des entrées / sorties
HCM Beginner (IV) - time
mysql数据类型学习笔记
C语言课设学生信息管理系统(大作业)
Rotate the animation component around the circle, take it and use it directly
Pol8901 LVDS to Mipi DSI supports rotating image processing chip
Find the original array for the inverse logarithm
PAT (Advanced Level) Practice 1057 Stack
Common shortcut keys
脏读、幻读和不可重复读
存储过程学习笔记
Mysql 表分区创建方法
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
C language course set up property fee management system (big work)
Functions of switch configuration software
下载外文期刊的方法
Student attendance system for C language course (big homework)