Xwiki 12.9 LibreOffice not starting

We are running Xwiki 12.9 on Ubuntu 18.04.5 LTS (Bionic Beaver). After installing LibreOffice apt-get install libreoffice version: 1:6.0.7-0ubuntu0.18.04.10 and enabling it in the conf, restarting Tomcat9 produces the error:

Error while connecting / starting the office server.

Originally I found that LibreOffice was trying to write to the tomcat home directory, so I added ReadWritePaths=/local/home/tomcat to /etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf, and after configuring the tomcat home dir, resolved that issue. However, I still cannot get it to start. If I run tomcat as root it works, but starting it from systemd (tomcat user) fails.

I have tried enabling TRACE logging for org.xwiki.officeimporter.server, but I receive no further messages describing the error.

Here is the config:

#-------------------------------------------------------------------------------------
#Settings for the OpenOffice server instance consumed by the OfficeImporter component
#-------------------------------------------------------------------------------------

#-# [Since 1.9M2]
#-# Type of the openoffice server instance used by officeimporter component.
#-# 0 - Internally managed server instance. (Default)
#-# 1 - Externally managed (local) server instance.
openoffice.serverType = 0

#-# [Since 12.1RC1]
#-# Port numbers used for connecting to the openoffice server instance.
#-# For an internally managed server instance, it will create the process for all ports.
#-# For an externally managed server instance, only the first server port is taken into account.
openoffice.serverPorts = 8100,8101

#-# [Since 1.9M2]
#-# If the openoffice server should be started / connected upon XE start.
#-# Default value is false
openoffice.autoStart = true

#-# [Since 1.8RC3]
#-# Path to openoffice installation (serverType:0 only).
#-# If no path is provided, a default value will be calculated based on the operating environment.
openoffice.homePath = /usr/lib/libreoffice/

#-# [Since 1.8RC3]
#-# Path to openoffice execution profile (serverType:0 only).
#-# If no path is provided, a default value will be calculated based on the operating environment.
#openoffice.profilePath = /home/user/.openoffice.org/3

#-# [Since 1.8RC3]
#-# Maximum number of simultaneous conversion tasks to be handled by a single openoffice process (serverType:0 only).
#-# Default value is 50
#openoffice.maxTasksPerProcess = 50

#-# [Since 1.8RC3]
#-# Timeout for conversion tasks (in milliseconds) (serverType:0 only).
#-# Default value is 60 seconds
#openoffice.taskExecutionTimeout = 60000

From catalina.out, one message stands out: Office process died with exit code 77:

2020-12-09 13:20:56,304 [main] ERROR .OfficeServerLifecycleListener - Error while connecting / starting the office server.
org.xwiki.officeimporter.server.OfficeServerException: Error while connecting / starting the office server.
at org.xwiki.officeimporter.internal.server.DefaultOfficeServer.start(DefaultOfficeServer.java:208)
at org.xwiki.officeimporter.internal.server.OfficeServerLifecycleListener.startOfficeServer(OfficeServerLifecycleListener.java:98)
at org.xwiki.officeimporter.internal.server.OfficeServerLifecycleListener.onEvent(OfficeServerLifecycleListener.java:85)
at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:320)
at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:285)
at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:337)
at org.xwiki.container.servlet.XWikiServletContextListener.contextInitialized(XWikiServletContextListener.java:127)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4668)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5136)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:631)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1832)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:526)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:425)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:496)
Caused by: org.jodconverter.office.OfficeException: Office process died with exit code 77
at org.jodconverter.office.ConnectRetryable.attempt(ConnectRetryable.java:87)
at org.jodconverter.office.AbstractRetryable.execute(AbstractRetryable.java:76)
at org.jodconverter.office.ConnectRetryable.execute(ConnectRetryable.java:26)
at org.jodconverter.office.OfficeProcessManager.doStartProcessAndConnect(OfficeProcessManager.java:104)
at org.jodconverter.office.OfficeProcessManager.lambda$startAndWait$3(OfficeProcessManager.java:243)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jodconverter.office.OfficeConnectionException: Connection failed: ‘socket,host=127.0.0.1,port=8100,tcpNoDelay=1’; java.net.ConnectException: Connection refused (Connection refused)
at org.jodconverter.office.OfficeConnection.connect(OfficeConnection.java:172)
at org.jodconverter.office.ConnectRetryable.attempt(ConnectRetryable.java:61)
… 8 common frames omitted
Caused by: com.sun.star.connection.NoConnectException: java.net.ConnectException: Connection refused (Connection refused)
at com.sun.star.lib.connections.socket.socketConnector.connect(socketConnector.java:144)
at com.sun.star.comp.connections.Connector.connect(Connector.java:119)
at org.jodconverter.office.OfficeConnection.connect(OfficeConnection.java:106)
… 9 common frames omitted

Googling around it appears that Office process died with exit code 77 is a permissions issue…

Any insight would be greatly appreciated.

Hi,

do you have any firewall on your machine that might prevent LibreOffice to communicate on port 8100?
In any case you might want to open an issue directly on jodconverter’s project: Issues · jodconverter/jodconverter · GitHub this is what XWiki is using to communicate with LibreOffice and clearly the error is outside of XWiki itself.

In any case would be great if you could create an issue on Loading... regarding this and continue the discussion there since there might be something we can do on XWiki side once a fix is found (upgrade jodconverter after some fix, add more stuff to /etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf to help this use case, etc.).

The root cause of the issues is most probably the fact that Tomcat is running in systemd but I don’t know libreoffice server enough to suggest things to try.

Thanks @surli and @tmortagne. No firewall running. I have opened issues on GitHub jodconverter as well as Xwiki Jira.

Cheers,
-T