Following previous advice from support, we have packaged the groupdocs modules in a standalone Java app, the main goal being to avoid crashing the app server when document conversion crashes.
We have recently fount that the following NPE occurs while running on Java 17, but does not occur on Java 8; see stack trace for details.
The conversion process runs on a Debian bookworm box; fonts have been installed and checked; however, seeing that changing the java version allows the document conversion to run, one’s conclusion is that it’s not a missing font problem.
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:209) ~[na:na]
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:263) ~[na:na]
at java.base/java.nio.file.Path.of(Path.java:147) ~[na:na]
at java.base/java.nio.file.Paths.get(Paths.java:69) ~[na:na]
at com.groupdocs.viewer.fonts.k.E(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.domain.documents.E.b(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.domain.documents.i.a(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.Viewer.a(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.Viewer.a(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.domain.f.b.a(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
at com.groupdocs.viewer.Viewer.view(Unknown Source) ~[groupdocs-total-25.12.jar:25.12]
The problem can be easily addressed by using a Java 8 setup, but it will reach its end-of-life in a not-so-distant future, so any help or suggestions is appreciated.
Best regards.
Hello @stefanu123 ,
Thank you for the detailed information and for providing the stack trace.
To help us investigate this issue, could you please share the following information, if possible?
- The Dockerfile (or Docker image configuration) used for your Java 17 environment.
- A code sample demonstrating, where the exception occurs.
- If possible, the input document that consistently reproduces the problem.
Having these details will allow us to reproduce the issue in our environment and perform a thorough investigation.
Hello @stefanu123 ,
We reproduced the issue on our side and logged it as VIEWERJAVA-4126. We will notify you once the fix is released.
In the meantime, we would suggest trying the following workaround until the fix is shipped in a release. Since you are running the conversion inside a Docker container, please add the following to your Dockerfile:
ENV LOCALAPPDATA=/tmp/_unused_localappdata
or to your docker-compose.yml:
environment:
LOCALAPPDATA: /tmp/_unused_localappdata
Please confirm whether this resolves the crash on your side.
Thanks for the update on the ticket; I will however add the requested info, maybe it comes in handy sometime.
The Dockerfile (or Docker image configuration) used for your Java 17 environment.
We have the issue on a linux machine, not a container.
A code sample demonstrating, where the exception occurs.
It’s pretty basic.
try (InputStream license = getClass().getResourceAsStream(LICENSE_FILE_PATH))
{
com.groupdocs.viewer.License licenseViewer = new com.groupdocs.viewer.License();
licenseViewer.setLicense(license);
PdfViewOptions viewOptions = new PdfViewOptions(fileOut.toPath());
LoadOptions loadOptions = new LoadOptions();
loadOptions.setDetectCharset(true);
try (Viewer viewer = new Viewer(fileIn.toPath(), loadOptions))
{
viewer.view(viewOptions);
}
}
If possible, the input document that consistently reproduces the problem.
Any doc or docx file, but here’s a sample
simple word file.docx (12.9 KB)
Best regards.
@stefanu123 ,
Thank you for the additional details — we have attached them to ticket VIEWERJAVA-4126.
Since you are running on a Linux host (not a container), the same workaround applies — just set the LOCALAPPDATA environment variable for the JVM process.
You can test this in one of the following ways:
For a one-time test:
LOCALAPPDATA=/tmp/_unused_localappdata java -jar your-app.jar
Or, if you are using a startup script, add the following before launching Java:
export LOCALAPPDATA=/tmp/_unused_localappdata
These options temporarily set the required environment variable for the Java process and can help verify whether this workaround resolves the issue. Please confirm whether this resolves the crash on your side.