Hello, we are also experiencing this issue on our project.
Subject: NullPointerException
during updateFields()
on Mail Merge with Letter Template (Aspose.Words for Java)
BSL1.pdf (392.2 KB)
Product: Aspose.Words for Java
Version: 23.12
Java Version: OpenJDK 17
Description:
We’re encountering a NullPointerException
when calling Document.updateFields()
on a template document during a mail merge process. The exception is thrown internally by Aspose, with no custom code involvement in the failing stack frame. This seems to be caused by some specific content in our Word template (attached as PDF, not able to upload the Word template), likely related to field codes or layout.
Stack Trace (sanitized):
java.lang.NullPointerException: Cannot invoke "com.aspose.words.zzZOh.zzWhW()" because the return value of "com.aspose.words.zzZOh.zzZ85()" is null
at com.aspose.words.zzZME.zzZ3J(Unknown Source)
at com.aspose.words.zzZME.zzW(Unknown Source)
at com.aspose.words.zzZME.zzY(Unknown Source)
at com.aspose.words.zzZME.zzZ(Unknown Source)
at com.aspose.words.zzZME.zzb(Unknown Source)
at com.aspose.words.Field.updateCore(Unknown Source)
at com.aspose.words.Field.update(Unknown Source)
at com.aspose.words.Field.unlink(Unknown Source)
at com.aspose.words.Field.remove(Unknown Source)
at com.aspose.words.Range.updateFields(Unknown Source)
@neterga Could you please attach your template and code that will allow us to reproduce the problem? We will check the issue and provide you more information. If your template file extension is not supported for upload in the forum, please zip it and upload ZIP archive.
BSL_BEREGN_INDTRAEDEN.zip (181.3 KB)
Thank you! I have attached a zipped version of the Word template.
Regards
Erik
@neterga Thank you for additional information. The problem is not reproducible with the latest 25.7 version of Aspose.Words and the following simple code:
Document doc = new Document("C:\\Temp\\in.dotx");
doc.updateFields();
Please try using the latest version on your side and let us know if the problem still persists on your side.
Hello,
Thank you for the quick reply.
Unfortunately we cannot simply update to the newest version.
Is the error reproducible with your teststeps in 23.12? If not, it would suggest the issue is not reproducible using your current test method.
If it is reproducible in 23.12, is there any suggestions to how we can change the template or any way to avoid the error in our current version, until we are able to update to the newest version?
Mvh
Erik
@neterga I tested the same code with 23.12 version of Aspose.Words for Java on my side and the problem is not reproducible. Could you please provide a simple code that will allow us to reproduce the problem?
Hello,
We do not have any code to reproduce the error.
We are not able to reproduce this error with any form of code, it is only appearing in our live production environment, sporadically, on some documents using the same template. A large part of the documents using the attached template are merging successfully, but some fail with this error, with no apparent pattern.
Can you give some information regarding what this specific stacktrace means? Is it possible to define what is causing the stacktrace in your code, so that we can try to prevent it on our side?
Regards
Erik
@neterga Unfortunately, without ability to reproduce the problem it is hard to tell what can cause the problem on your side. The provided stack trace also does not give enough information for analysis, I am afraid.
Is it not possible from your side to see what the issue is with the obfuscated method names in the stacktrace?
java.lang.NullPointerException: Cannot invoke "com.aspose.words.zzZOh.zzWhW()" because the return value of "com.aspose.words.zzZOh.zzZ85()" is null
at com.aspose.words.zzZME.zzZ3J(Unknown Source)
at com.aspose.words.zzZME.zzW(Unknown Source)
at com.aspose.words.zzZME.zzY(Unknown Source)
at com.aspose.words.zzZME.zzZ(Unknown Source)
at com.aspose.words.zzZME.zzb(Unknown Source)
at com.aspose.words.Field.updateCore(Unknown Source)
at com.aspose.words.Field.update(Unknown Source)
at com.aspose.words.Field.unlink(Unknown Source)
at com.aspose.words.Field.remove(Unknown Source)
at com.aspose.words.Range.updateFields(Unknown Source)
Regards
Erik
@neterga I asked our Java developers to take a look. But I am doubt that deobfuscated stack trace will give enough information to determine the root cause of the problem.
Ok, thank you @alexey.noskov .
Any hint or pointer will be appreciated, so please let me know when you get an answer from the developers.
Regards
Erik
1 Like
Hello, are there any news from your developers @alexey.noskov ?
This error is quite urgent for us, as it is affecting real life citizens in production as we speak.
Regards
Erik
@neterga Unfortunately, I did not get response from developers yet. I will keep you updated.
@neterga
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSJAVA-3145
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi @neterga
I can’t decode StackTrase with version 23.12 and I checked other version of Aspose.Words for Java and found code from StackTrace in version 23.9
Finally the StackTrase looks like:
java.lang.NullPointerException: Cannot invoke "com.aspose.words.LayoutLogicalBase.getLayoutType()" because the return value of "com.aspose.words.LayoutLogicalBase.getParent()" is null
I found method with error:
LayoutLogicalBase getNextTopLevelContentLayout()
{
boolean isTopContent = (getLayoutType() == LayoutType.ROW && getParent().getParent().getLayoutType() == LayoutType.SECTION) ||
(getLayoutType() == LayoutType.PARAGRAPH && getParent().getLayoutType() == LayoutType.SECTION);
I added fix and it should be included in Aspose.Words for Java 25.8 release
Regards
Anatoly