Issue 97227 - soffice bin 100% CPU in linux in headless mode?
Summary: soffice bin 100% CPU in linux in headless mode?
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: OOo 3.0
Hardware: Unknown Linux, all
: P3 Trivial with 5 votes (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
: 94471 125886 (view as issue list)
Depends on: 63270
  Show dependency tree
Reported: 2008-12-13 11:30 UTC by prashanth_bhat
Modified: 2019-08-01 22:10 UTC (History)
11 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

Source code (13.10 KB, text/plain)
2008-12-16 10:09 UTC, prashanth_bhat
no flags Details
Code to convert files to PDF (1.73 KB, text/plain)
2017-07-01 08:01 UTC, akataria
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description prashanth_bhat 2008-12-13 11:30:53 UTC
if I use xdesktop.terminate() the soffice bin thread is killed and releases the CPU
but why does soffice bin take 100% CPU Utilization. it takes all CPU Usage and
causes the the other applications to slowdown/hang.

Am i doing something wrong? I am just opening swriter and writing one document
so does openoffice really workout in a production web environment having
multiple users?

No matter which version of soffice for linux without jre it gives the same
problem. i have tested with 2.4.2 and 3.0 versions of office

I am starting openoffice as a server in headless mode
./program/soffice -headless -invisible -nologo -norestore
-accept="socket,host=,port=8100;urp;" -nofirststartwizard &

below is the code

XComponent xEmptyWriterComponent = newDocComponent("swriter");
// query its XTextDocument interface to get the text
mxDoc = (XTextDocument)UnoRuntime.queryInterface(
XTextDocument.class, xEmptyWriterComponent);

// get a reference to the body text of the document
mxDocText = mxDoc.getText();

// Get a reference to the document's property set. This contains document
// information like the current word count
mxDocProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDoc );

// Access the text document's multi service factory, which we will need
// for most of the following examples
mxDocFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class, mxDoc );
mxFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, mxRemoteServiceManager);
if ( mxDoc != null ) {
XStorable xStorable = (XStorable)UnoRuntime.queryInterface(
XStorable.class, mxDoc);
PropertyValue[] storeProps = new PropertyValue[3];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "FilterName";
storeProps[0].Value = "MS Word 97";
storeProps[ 1 ] = new PropertyValue();
storeProps[ 1 ].Name = "UpdateDocMode";
storeProps[ 1 ].Value = "1";
storeProps[ 2 ] = new PropertyValue();
storeProps[2].Name = "Overwrite ";
storeProps[2].Value = new Boolean(true);

File sourceFile2 = new;
StringBuffer sStoreFileUrl2 = new StringBuffer();
System.out.println("... stored ");
xStorable.storeAsURL(sStoreFileUrl2.toString(), storeProps); xCloseable = ( )
xEmptyWriterComponent );
// mxDoc.dispose();
mxRemoteServiceManager =null;
mxRemoteContext= null;
// xDesktop.terminate(); //kill soffice bin takes 100% CPU if you dont
// printDocComponent(xDoc);
protected XComponent newDocComponent(String docType)
throws java.lang.Exception
String loadUrl = "private:factory/" + docType;
mxRemoteServiceManager = this.getRemoteServiceManager();
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"", mxRemoteContext);

xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
// PropertyValue[] loadProps = new PropertyValue[0]; loadProps[] =
loadProps[0] = new;
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
XComponent xComp = xComponentLoader.loadComponentFromURL(loadUrl, "_blank",
0, loadProps);
xComponentLoader =null;
return xComp ;

actually it is from one of the samples too
Help Appreciated.
Comment 1 prashanth_bhat 2008-12-13 11:38:07 UTC
also long after the program is exited and the writer is closed the soffice bin
continues to use 100% CPU. what might be the issue ? I downloaded the tar
extracted it and the RPMS in the folder and am running soffice as non root

I am starting openoffice as a server in headless mode
./program/soffice -headless -invisible -nologo -norestore
-accept="socket,host=,port=8100;urp;" -nofirststartwizard &
Comment 2 eric.savary 2008-12-13 12:43:13 UTC
Not a P1. Changing component
Comment 3 Olaf Felka 2008-12-13 12:53:59 UTC
@ sg: Please have a look.
Comment 4 prashanth_bhat 2008-12-14 13:02:48 UTC
Hi sg,

Any solutions?. the windows version seems to work fine it releases the cpu 
atleast after the document is closed but since our production web environment 
is linux. it has to work on a linux box. the document is created and closed 
properly but the soffice bin thread continues to use 100% cpu. Also hope the 
same socket connection can be used in a web env. over multiple sessions and it 
wont lead to memory leaks and cpu usage problems.

Help Appreciated,
Comment 5 prashanth_bhat 2008-12-14 13:56:03 UTC
I am using jRE 1.4.2 even though i dont think that is the problem.
Comment 6 steffen.grund 2008-12-15 13:22:33 UTC
Can you explain more exactly what you do? I had to edit your code a bit to let
it run - and then I could not reproduce the behavior. But then nothing really
exciting was done: an empty writer document was stored using the MS Word 97 filter.
Could you please create an attachment with a complete compilable source file
that shows the bug? Or, even better, just tell me which sample is it?
FYI: I did use an 2.6.15 kernel on i686 hardware.
Comment 7 prashanth_bhat 2008-12-16 10:09:12 UTC
Created attachment 58848 [details]
Source code
Comment 8 prashanth_bhat 2008-12-16 10:12:09 UTC
Hi sg,

long after the program is exited and the writer is closed the soffice bin
continues to use 100% CPU. what might be the issue ? I downloaded the tar
extracted it and the RPMS in the folder and am running soffice as non root

I am starting openoffice as a server in headless mode
./program/soffice -headless -invisible -nologo -norestore
-accept="socket,host=,port=8100;urp;" -nofirststartwizard &

I dont know whether the way i installed was wrong because i just extracted the 
tar and extracted the RPMS in that folder

Comment 9 steffen.grund 2008-12-16 11:11:05 UTC
Well, if the Office is running, the way you installed cannot be that wrong. But
still - I do not see 100% CPU usage, even when the Office is converting the
What Linux distribution do you have and what machine does run on?
Another question, what does BootstrapSocketConnector.bootstrap(oooExeFolder)
(line 295) do?
Comment 10 prashanth_bhat 2008-12-16 11:18:06 UTC;
since the above code was not able to connect to a running office instance.
I used the bootstrapconnector.jar 

BootstrapSocketConnector.bootstrap(path to office executable)
Comment 11 prashanth_bhat 2008-12-16 11:39:09 UTC
Linux 2.6.9- #1 SMP Thu Jul 5 10:25:39 PDT 2007 x86_64 x86_64 
x86_64 GNU/Linux

Oracle Linux x86_64 64 bit

It is a 64 bit machine
Comment 12 prashanth_bhat 2008-12-17 12:17:26 UTC
I Installed openoffice linux RPM not the 64 bit version on a linux 64 bit. 
maybe that's the problem
Comment 13 prashanth_bhat 2008-12-20 15:34:06 UTC
Hi sg,

I Installed 64bit office rpm and it does not seem to be giving that problem. 
though I was able to reproduce that problem also once on 64 bit rpm.does a 
corrupt profile create the problem? I am not sure.


1)I have used a single connection across sessions in a web application to the 
office instance. I have stored RemoteServiceManager and RemoteContext in
and use it for all sessions. the connection will be used  
throughout the lifecycle of the application and I am not using 
xdesktop.terminate() so the soffice bin singleton instance will keep servicing 
the web client requests and never be closed. Is this feasible?. Will it give 
rise to memory and CPU problems? 

Any advise will be useful since it will be used in a production setup

Comment 14 nleonard 2009-11-12 17:08:47 UTC
Any news from this problem ?

I have the same symptoms when launching soffice.bin in headless mode

  OS: Linux Debian Lenny 64 bits
  OOO: 2.4.1
  CPU : Intel Core2 Duo 
Comment 15 joragupra 2011-04-19 14:00:59 UTC
I have the same problem too, I think. In a test program running on a Windows machine it works fine but when I run the same program on Linux, the soffice process takes 99.9% CPU usage and my application can't connect to OpenOffice to transform documentos to PDF.

This is the test class that tries to launch soffice with -headless mode:

package com.ooffice;

import java.util.Map;


public class ClienteOOffice {
	/*                                                                    */
	/*                          CONSTANTES PUBLICAS                       */
	/* deberian estar configuradas en un fichero de propiedades o similar */
	/*                                                                    */
	public static final String OOFFICE_PATH = "/opt/openoffice.org2.4/program/soffice";
	private static final String SOCKET_OPTS = "-accept=socket,host=localhost,port=";
	public static final int TIEMPO_ESPERA = 3000;
	public static final int PUERTO_INICIAL = 2003;
	public static final String SO_HOST = "LINUX"; //'WINDOWS' or 'LINUX'
	/*                                                                    */
	/*                     FIN  CONSTANTES PUBLICAS                       */
	/*                                                                    */
	private static final int NUMERO_DOCUMENTOS_GENERADOS = 10;
	private static final String PIE = "Y esto va en el pie del nuevo documento.";

	private static final String CABECERA = "Esto va en la cabecera";

	private static final String RUTA_FICHERO_PLANTILLA = "/tmp/ooffice/ND_NOTIFICACION.sxw";

	private static final String RUTA_FICHERO_GENERADO = "/tmp/ooffice/GEN_ND_NOTIFICACION.sxw";

	private static final String INICIO_BOOKMARK = "inicio_decreto";

	private static final String FIN_BOOKMARK = "fin_decreto";

	private static final String TARGET_BOOKMARK = "inicio_decreto";
	 * <p>
	 * Genera tantos documentos como se definan en 
	 * <code>NUMERO_DOCUMENTOS_GENERADOS</code>. Se pueden lanzar varias 
	 * instancias de ejecuci&oacute;n para comprobar el comporamiento simulado 
	 * de varios usuarios generando documentos simult&aacute;neamente.
	 * </p>
	 * @param args
	public static void main(String[] args) {
		ClienteOOffice prueba = new ClienteOOffice();
		for (int i = 0; i < NUMERO_DOCUMENTOS_GENERADOS; i++) {
			System.out.println("Generando documento " + (i+1));
	 * <p>
	 * Muestra c&oacute;mo se deben generar los documentos en 3 pasos para que 
	 * no haya problemas con la memoria consumida por el proceso soffice.bin:
	 * </p>
	 * <p><ol>
	 * <li>Buscar un puerto a partir del inicial que est&eacute; libre para 
	 * poder arrancar el proceso soffice.bin</li>
	 * <li>Iniciar el proceso soffice.bin en el puerto indicado</li>
	 * <li>Conectar la aplicaci&oacute;n con el servidor OpenOffice arrancadoo 
	 * en el puerto que se encontr&oacute;</li>
	 * <li>Generar el documento</li>
	 * </ol></p>
	 * @return
	public int generarDocumento() {
		System.out.println("Buscando puerto libre...");
		ServerSocket socket = buscarPuertoLibre(PUERTO_INICIAL);
		System.out.println("Puerto encontrando: " + socket.getLocalPort());
		System.out.println("Iniciando proceso soffice...");
		Process p = iniciarProcesoOpenOffice(socket.getLocalPort());
		int result = TableGenerator.betweenBookmarks(RUTA_FICHERO_PLANTILLA,
				crearFicheroDestino(), INICIO_BOOKMARK, FIN_BOOKMARK,
		System.out.println("Parando proceso soffice...");
		System.out.println("Liberando puerto " + socket.getLocalPort() + "...");
		try {
		} catch (IOException e) {
		return result;
	public ServerSocket buscarPuertoLibre(int initPort){
		ServerSocket socket = null;
		int puerto = initPort;
			try {
				socket = new ServerSocket(puerto);
			} catch (IOException e) {
				socket = null;
		return socket;
	public Process iniciarProcesoOpenOffice(int puerto){
		try {
			System.out.println("Ejecutando commando " + OOFFICE_PATH + 
				    SOCKET_OPTS + puerto + ";urp;StarOffice.ServiceManager"
				    + "-headless" + "-nologo" + " -nofirststartwizard");
			ProcessBuilder pb = new ProcessBuilder(OOFFICE_PATH,
				    SOCKET_OPTS + puerto + ";urp;StarOffice.ServiceManager",
				    "-headless", "-nologo", "-nofirststartwizard");
			Map<String, String> env = pb.environment();
			if ("WINDOWS".equals(SO_HOST)) {
				System.out.println("Estableciendo entorno " + "c:\\user" + puerto);
			    env.put("USERPROFILE", "c:\\user"+puerto);
			} else {
				System.out.println("Estableciendo entorno " + "/tmp/user" + puerto);
			    env.put("HOME", "/tmp/user"+puerto);
			System.out.println("Arrancando proceso...");
			Process result = pb.start();
			Thread t = Thread.currentThread();
			synchronized (t) {
				try {
				} catch (InterruptedException e1) {
			System.out.println("Proceso arrancado despues de espera de " + TIEMPO_ESPERA + " ms");
			return result;
		} catch (IOException e) {
			return null;

	 * <p>
	 * Copia el fichero de <code>RUTA_FICHERO_GENERADO</code> a&ntilde;adiendo 
	 * un sufijo al mismo (sacado de <code>System.currentTimeMillis</code>) y 
	 * devuelve la ruta del nuevo fichero.
	 * </p>
	 * @return
	private String crearFicheroDestino() {
		File original = new File(RUTA_FICHERO_GENERADO);
		String[] ficheroExtension = RUTA_FICHERO_GENERADO.split("\\.");
		File copia = new File(ficheroExtension[0] + "_"
				+ System.currentTimeMillis() + "." + ficheroExtension[1]);
		try {
			FileUtils.copyFile(original, copia);
		} catch (IOException e) {
		return copia.getAbsolutePath();
Comment 16 richard 2014-10-27 16:31:37 UTC
I have exactly the same problem under Linux 64 bits.
I use the Java API to access the soffice exectubale, and after a first generation, soffice executable uses 100% CPU indefinitely.

I have reproduce the problem under soffice 4.0.1 and libreoffice 4.2
Comment 17 richard 2014-10-27 16:32:58 UTC
If I use my Java program to access a windows soffice instance, the process behaves normally.
Comment 18 oooforum (fr) 2014-11-21 13:24:46 UTC
*** Issue 125886 has been marked as a duplicate of this issue. ***
Comment 19 akataria 2017-06-30 13:25:39 UTC
I have this same issue. I don't see a solution of it anywhere. I don't think these tickets should be closed as duplicates. I don't see any resolution on any of the tickets
Comment 20 akataria 2017-06-30 13:29:30 UTC
Can someone please take a look I'm trying to convert files using JOD library, which internally uses Apache OpenOffice(4.1.2). I'm using CentOS7 machine. I have pretty much tried every command line option out there, but none of it seems to solve the problem. 
Here's the command I'm using:

/opt/openoffice4/program/soffice.bin -accept=socket,host=,port=8016;urp; -env:UserInstallation=file:///tmp/.jodconverter_socket_host- -headless -nocrashreport -nodefault -nofirststartwizard -nolockcheck -nologo -norestore
Comment 21 Peter 2017-06-30 23:17:55 UTC
A bug is closed as a duplicate because we believe that the reported issue is the same as another one.
In this case this issue report is also not closed but marked as unconfirmed. Which mean that Apache Open Office tester have not been able to reproduce the issue in their environment.
The rule here is simple, if we can reproduce an issue we are sure that It is a problem within open office. We can fix it.
If we cannot reproduce the issue we lack information.

So now for your case.
You use an "unmaintained" third party software which uses Open Office to do the conversion. Possible the author switched to Libre. At least that is what github suggests in a way.

Can you provide more information please?
Where did you download JOD and which version do you use?

I'll take a look.

All the best 
Comment 22 akataria 2017-07-01 08:01:20 UTC
Created attachment 86162 [details]
Code to convert files to PDF
Comment 23 akataria 2017-07-01 08:14:09 UTC
Thanks Peter for prompt response. I agree the library is unmaintained for a while now, however, in our load-test we found that the CPU Utilization shoots up as soon as the request gets handed over to OpenOffice, and in the result of htop the CPU Utilization is governed by soffice.bin process.

I'm using jodconverter-core-3.0-beta-4-jahia2.jar jar for converting the files.
I'm also attaching a zip file you would need to run the program ( 

I have also attached the code I'm using to convert the files( All you need to do is run the java file. Give your OpenOffice installation location. For mac it is = /Applications/ and for Linux it is = /opt/openoffice4/

As soon as you run the java program and the conversion starts CPU Utilization shoots upto 100%

Please let me know -if you need any further details thanks!
Comment 24 akataria 2017-07-01 08:26:36 UTC
You can download the Jars from:
Comment 25 akataria 2017-07-07 12:41:40 UTC
Hi Peter,
Anything here?
Comment 26 Peter 2017-07-09 15:22:57 UTC
Sorry did not manage to prepare, I haven't forgotten you. I hope I can test on the upcoming week.
Really sorry.
Comment 27 Peter 2017-07-12 01:52:25 UTC
Hi your information seems to be grown over time.

The Java file you have added is way out of date.
JoD requires to setup the tool differently.

I add your thread in Forum for reference:

Can you please elaborate what your usecase is?
(In business terms not on technical doing.) What do you want to achieve?
Comment 28 akataria 2017-07-12 12:07:41 UTC
Hi Peter,
Thanks for getting back.

I'm not sure -if I followed you correctly. What do you mean by my "Java file is way out of date"?

Our use case is basically to convert all the documents(Word, Excel, PowerPoint) to PDF, and for that we have choose to use Apache OpenOffice and JOD is just a java wrapper around OpenOffice.

We have found the CPU utilization to be reaching 100% of OpenOffice processes which messes up out load balancing auto-scale architecture
Comment 29 Peter 2017-07-18 08:33:24 UTC
> I'm not sure -if I followed you correctly. What do you mean by my "Java file is way out of date"?

I mean your source code file you uploaded has Copyright from sun.
Also it refers to interna of Open Office, which could have been changed from the version you have this code from to the version we publish today.

Maybe I got your source code upload wrong. But I would have expect that you reference JOD in your application Not Open Office.

From the documentation of JOD, I think they configure openoffice from the outside. So any reference into Open Office code looks suspiceous to me.

Do you use a J2EE server or is the conversion initiated by commandline?
If it is initiated by command line, a test with the Pyod tool could be helpfull and worth a try.
Comment 30 akataria 2017-07-18 10:11:41 UTC
Hi Peter,

First, I strongly believe there's anything wrong with JOD. Whole conversation around JOD seems a red herring to me.
Second, Please let me know what made you think the code has a copyright from Sun? Even if it is, how is that a problem?

Third, please elaborate on what is suspicious in referring internals of OpenOffice? Its a wrapper so it is supposed to refer the internals, I would be worried -if I see it changing/modifying internals, which I don't see it doing.

Fourth, again, JOD does refer from outside, what's the suspicion? Please be more elaborative and succinct.

Lastly, OpenOffice servers are started through command line and the conversion requests are served by Netty server in our case. Again, I feel this point is moot and not worth talking about in this context. I don't know how we can convert from direct command line using OpenOffice but I tried direct command line conversion using Libre Office, and it also consumes 100% CPU.

Is there a command that will let me convert documents to PDF using OpenOffice right from command line? That would be our best bet to understand -if the problem is with OpenOffice or not since it eliminates anything related to JOD.
Comment 31 Peter 2017-07-18 17:45:34 UTC
The misunderstanding is on my side.
I never used this approach so I have to understand the case first. I am sorry for the inconvenience on your side.
In this case I somehow assumed the uploaded source code is from you but that's some old stuff.

In general I do not thing you need to program some Wrapperstiff, that should be handled by JOD.

If you search for pyod on the web there is an alternate python implementation. It is command-line based. So maybe it is worth a shot for experimentation, workaround.

Good to know that Libre causes the same issue. But that does not neccesarry point to a problem in JOD. Could be still Office side.

I suspect that the service is not closing properly. Hard to say if it is a wrapper issue or not.

Investigation is on going.
Comment 32 akataria 2017-07-18 18:17:33 UTC
Apologies Peter by anything I meant "nothing" in the previous comment. I can't believe there's no EDIT button in here.

*I most certainly believe the problem in on the OpenOffice side and NOT with JOD/PyOD.*

Moreover, JOD can also be used via command line its exactly the same as PyOD usage. I don't think that's gonna solve the problem.

For LibreOffice command line PDF conversion without using JOD this is the command I used: "/Applications/ --headless --convert-to pdf AdeemSample.xlsx"

I was wondering, if there's a similar command for OpenOffice that will help confirm my assertion about the problem being with OpenOffice.

Please keep me posted about the findings thanks!
Comment 33 Peter 2017-07-18 18:40:08 UTC
I don't know about the command you have mentioned from Libre.

I will update,when I can reproduce the issue. (Next step)
After this we'll see.
If I can not confirm. That would be also good hint for you.

Xls-> pdf good hint!
Comment 34 Peter 2018-09-23 16:44:45 UTC
Found a Bug that might be related. Maybe OpenOffice crashes at closing the document.

I have also now learned that my system does not create a socket on Linux. But on Windows socket creation works fine. So that is a step forward. Lets hope I get better at this. If someone else has more insight and can add more information thanks.
Comment 35 Peter 2018-09-23 17:02:35 UTC
*** Issue 94471 has been marked as a duplicate of this issue. ***
Comment 36 damjan 2018-10-02 17:17:18 UTC
The OP's sample code in the "Source code" attachment, patched a bit, by uncommenting:

sOutputDir = args[0];

and commenting the previous fixed path. Also comment out this non-existent dependency:

//import ooo.connector.BootstrapSocketConnector;

and comment this related line:

//  mxRemoteContext = BootstrapSocketConnector.bootstrap(oooExeFolder);

and uncomment this line near it:

mxRemoteContext =;

This DOES NOT reproduce the issue for me, on Linux 32, Linux 64, and FreeBSD 64, using the latest SVN trunk (I didn't test earlier versions). The file is written, and the CPU remains idle. I did it many times in a row. Still good.

Maybe that PDF converter still does. Let's see.
Comment 37 damjan 2018-10-02 17:19:29 UTC
(In reply to Peter from comment #35)
> *** Issue 94471 has been marked as a duplicate of this issue. ***

That bug seems to contain vital and pretty fundamental piece of information. Let me test "localhost" not resolving.
Comment 38 damjan 2018-10-02 17:42:48 UTC
Can't reproduce the 100% CPU issue even with the PDF converter (which seems hardcoded for Mac?) on Linux 64, even when I comment out localhost in /etc/hosts and disable DNS in /etc/resolv.conf. There is a failed assertion about socket.c but it seems harmless.
Comment 39 oooforum (fr) 2019-07-31 13:16:05 UTC
Thanks damjan for the feedback.
Set as irreproducible.