问题解决:OfficeException: failed to start and connect(一)

问题: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);

结果也是可以启动!

结论一:

所以最终问题在于杀死进程命令执行后,不能立马执行启动命令,会导致报错。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"Failed to start LSB: start and stop MySQL"错误信息表明MySQL无法成功启动。这个错误可能由多种原因引起,其中之一是权限问题。你可以检查MySQL的data目录的权限设置,确保MySQL有足够的权限来读取和写入该目录。另外,你还可以查看MySQL的配置文件,确认配置文件中的权限设置是否正确。如果你仍然遇到问题,你可以尝试以下方法来解决该错误: 1. 检查MySQL服务的状态:使用命令`systemctl status mysql`来查看MySQL服务的状态,如果服务没有运行,请尝试启动MySQL服务:`systemctl start mysql`。 2. 检查MySQL配置文件:查看MySQL的配置文件(通常是`/etc/mysql/my.cnf`或`/etc/my.cnf`),确保配置文件中的路径和权限设置正确。 3. 检查MySQL日志:查看MySQL的日志文件(通常是`/var/log/mysql/error.log`),查找任何与启动错误相关的信息。 4. 检查MySQL进程:使用命令`ps -ef | grep mysql`来检查是否有正在运行的MySQL进程。如果有,请尝试终止该进程,然后重新启动MySQL服务。 5. 重启服务器:如果上述方法都无效,你可以尝试重启服务器,有时候重启可以解决一些临时性的问题。 请注意,以上是一些常见的解决方法,具体解决方法可能因情况而异。如果问题仍然存在,请提供更多的详细信息,以便进一步帮助您解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [MySQL启动报错: Failed to start LSB: start and stop MySQL.](https://blog.csdn.net/firstcode666/article/details/121782924)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [MySQL启动报错: Failed to start LSB start and stop MySQL](https://blog.csdn.net/jiong9412/article/details/123676332)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [undefined](undefined)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值