java.lang.NullPointerException is Thrown while Loading DOCX in Docker Container Under Debian

I use Aspose Words for Java 18.4

Using the following code I’m not able to load any Word .docx document (a plain new one or with content):

final var doc = new Document(inputStream);

In my development Windows PC it works withtout problem, but in the production system in a docker container under Debian it fails.

Using the sentetce Locale.getDefault() I noted that the locale is de_US, can be that the problem?

Error:
Caused by: com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)

Caused by: java.lang.NullPointerException: null
at com.aspose.words.zzYZW.zzZmn(Unknown Source)
at com.aspose.words.zzYZW.zzZmp(Unknown Source)
at com.aspose.words.zzYZW.zzzj(Unknown Source)
at com.aspose.words.zz6.zzTO(Unknown Source)
at com.aspose.words.zz6.zzTP(Unknown Source)
at com.aspose.words.zzYZW.zzZmt(Unknown Source)
at com.aspose.words.zzYZW.zzZ(Unknown Source)
at com.aspose.words.zz98.visitSectionStart(Unknown Source)
at com.aspose.words.Section.zzZ(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Section.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Document.accept(Unknown Source)
at com.aspose.words.zz98.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)…

@grutta

Could you please ZIP and attach your input Word document along with simplified code example here for testing? We will investigate the issue and provide you more information on it.

It was solved, the problem was the locale de_US. For some reason that was automaticaly setted as de_US. When I fix to de_DE in the JVM enviroment variables, it works.

@grutta It is perfect that you managed to resolve the problem. I tried to reproduce the same error on my side using code like the following:

Locale currentLocale = Locale.getDefault();
Locale deUS = new Locale("de", "US");

System.out.println(Locale.getDefault());
Locale.setDefault(deUS);
System.out.println(Locale.getDefault());

Document doc = new Document("/Temp/in.docx");
doc.save("/Temp/out.pdf");

Locale.setDefault(currentLocale);

An the code works fine on both Windows and Linux Docker container. I used the foollowing Dockerfile for testing:

FROM openjdk:14
COPY testawjava.jar testawjava.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/testawjava.jar"]

Could you please share your Dockerfile? I would like to make sure the problem does not occur with the latest version of Aspose.Words.