Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: failed to read path from javaldx

An error occurs when converting a file using Libreoffice on ubuntu:

CompletedProcess(args=['soffice', '--headless', '--convert-to', 'txt:Text', '/var/www/Project/temp/e4bac2c2e7c04eb79cfa522967a30dd3.docx', '--outdir', '/var/www/Project/temp/'], returncode=77, stdout=b'', stderr=b'javaldx failed!\nWarning: failed to read path from javaldx\n')

Using subprocess:

process = subprocess.run(['soffice', '--headless', '--convert-to', 'txt:Text', path_docx, '--outdir', settings.TEMP_ROOT], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)

~# java --version

openjdk 11.0.6 2020-01-14 OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

like image 400
Evgenij Tsvetkov Avatar asked Feb 26 '20 12:02

Evgenij Tsvetkov


1 Answers

Ok found the solution:
If you are using libreoffice in headless, with a non root user, trying to convert a docx to a pdf, getting this error:

javaldx failed!
Warning: failed to read path from javaldx

Your user doesn't has a home folder set, or the home folder is not writeable. I just switched from calling libreoffice directly to calling it via a shell script like this:

export HOME=/opt/fhir-services && /usr/lib/libreoffice/program/./soffice --headless --invisible --convert-to pdf --outdir /opt/fhir-services /opt/fhir-services/tmp.docx

tomcat8 is the owner of this folder, now the conversion works.

like image 107
Patrick Werner Avatar answered Oct 23 '22 21:10

Patrick Werner