I want to add a solution I found while experiencing this issue.
I am running Libreoffice 6.4, Java openjdk 1.8.0, Apache 2.4.37 and PHP 8.2 as the restricted "apache" user with no home directory on an Oracle Linux 8 server that has SELinux enabled and enforcing. I have a php script with an exec statement that launched "soffice" to convert a file to html, and it was supposed to display the preview on the webapp.
$sofficeCmd = "export HOME=/tmp && /usr/bin/soffice --headless --convert-to html:HTML:EmbedImages $uploadedFilePath --outdir $uploadDir";
exec($sofficeCmd, $return, $res);
And I was still getting the error:
javaldx failed! Warning: failed to read path from javaldx LibreOffice 6.4 - Fatal Error: The application cannot be started. Extension Manager: exception during enableExtension
I had been struggling because I had tried almost all of the different recommended solutions I'd found across the many other stackoverflow/superuser/etc forum posts about this issue and it made no difference in the error.
What ended up being the problem was SELinux. The moment I set SELinux to permissive, the webapp correctly displayed the preview. There were two things I did to fix the issue:
1: I created a $webroot/tmp folder to act as the $HOME, and I set the folders SELinux type to "httpd_sys_rw_content_t".
2: Due to LibreOffice requiring Java, I also had to set the "httpd_execmem" SELinux boolean.
Disclaimer,
According to the RedHat Booleans documentation;
httpd_execmem
When enabled, this Boolean allows httpd to execute programs that require memory addresses that are both executable and writable. Enabling this Boolean is not recommended from a security standpoint as it reduces protection against buffer overflows, however certain modules and applications (such as Java and Mono applications) require this privilege.
I'm not 100% on the security implications here, but knowing soffice needs access to Java, and is being ran in a restricted environment through the apache user, this fixed the issue for me. Hopefully this solution is appropriate and someone else finds this useful :)