Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Wed Sep 03, 2025 12:55 pm
Dear support team,
after updating Spire.Doc for Java from 13.7.6 to 13.8.9 our document generation fails with the following exception:
- Code: Select all
Caused by: java.lang.NullPointerException: Cannot invoke "com.spire.doc.Section.getOwner()" because the return value of "com.spire.doc.BookmarkStart.spr⌭ㆀ()" is null
at com.spire.doc.collections.BookmarkCollection.spr¬┳—(Unknown Source)
at com.spire.doc.BookmarkStart.spr∯⅕(Unknown Source)
at com.spire.doc.DocumentObject.spr∯⅕(Unknown Source)
at com.spire.doc.DocumentObject.spr∯⅕(Unknown Source)
at com.spire.doc.DocumentObject.spr∯⅕(Unknown Source)
at com.spire.doc.collections.DocumentObjectCollection.spr▉’—(Unknown Source)
at com.spire.doc.collections.DocumentObjectCollection.add(Unknown Source)
at com.spire.doc.collections.RowCollection.add(Unknown Source)
This is my code:
- Code: Select all
public static List<TableRow> appendRows(final Table table, final Collection<TableRow> rows) {
List<TableRow> appendedRows = new ArrayList<>();
for (TableRow row : rows) {
TableRow copiedRow = row.deepClone();
table.getRows().add(copiedRow);
appendedRows.add(copiedRow);
}
return appendedRows;
}
This statement causes the exception:
table.getRows().add(copiedRow);
Can I ask for a bug fix, please?
Kind regards,
Marcus
-

mgattinger
-
- Posts: 65
- Joined: Fri May 21, 2021 9:03 am
Wed Sep 03, 2025 1:31 pm
I'll investigate this error as it also occurs in version 13.7.6.
-

mgattinger
-
- Posts: 65
- Joined: Fri May 21, 2021 9:03 am
Thu Sep 04, 2025 6:55 am
As far as I found out, the error dissappears if all bookmarks are removed before the given rows are appended to the given table (see code from my previous post).
- Code: Select all
for (int bookmarkIndex = document.getBookmarks().getCount() - 1; bookmarkIndex >= 0; bookmarkIndex--) {
document.getBookmarks().removeAt(bookmarkIndex);
}
The bookmarks removed are only hidden bookmarks that belong to the TOC.
Please have a look into it. What could cause this error?
-

mgattinger
-
- Posts: 65
- Joined: Fri May 21, 2021 9:03 am
Thu Sep 04, 2025 7:13 am
Hello,
Thank you for your inquiry.
I simulated a simple document and conducted preliminary tests, but did not reproduce the issue you mentioned. Could you please provide us with your input files or a complete runnable code demo? This information will help us investigate your issue more accurately and offer an effective solution. You may upload the files as attachments or send them directly to my email:
[email protected]. Thanks in advance.
Sincerely,
Talia
E-iceblue support team
-


talia.liu
-
- Posts: 331
- Joined: Mon Apr 14, 2025 3:33 am
Thu Sep 04, 2025 9:51 am
I did some further testing and I guess I have found the reason.
I have a table row that contains a bookmark (in this case it was a hidden bookmark that is part of a TOC). This table row in cloned using the method deepClone(). As soon as the cloned table row is added to the table again the error occurs.
My solution is to remove the bookmark that is contained in the table row (well in a table cell) to be cloned before it is cloned.
-

mgattinger
-
- Posts: 65
- Joined: Fri May 21, 2021 9:03 am
Thu Sep 04, 2025 3:12 pm
I really tried my best to set up a simple test project I can send you but I wasn't able to reproduce the error outside of our product.
Only thing I can say for sure is that is has something to do with TOC-related bookmarks inside a table row that is cloned in order to be appended multiple times into the same table.
-

mgattinger
-
- Posts: 65
- Joined: Fri May 21, 2021 9:03 am
Fri Sep 05, 2025 2:16 am
Hello,
Thank you for your feedback.
I'm very sorry. Based on the current information, I'm unable to determine the cause of your problem. If possible, please send us your code and related files. We will conduct further investigations. You may upload the files as attachments or send them directly to my email:
[email protected]. Thanks in advance.
Sincerely,
Talia
E-iceblue support team
-


talia.liu
-
- Posts: 331
- Joined: Mon Apr 14, 2025 3:33 am