Getting IllegalStateException

Hi,
When I am using the below code :

StructuredDocumentTag newSection = (StructuredDocumentTag) repeaterTemplate.deepClone(true);
Node insertedNode = compositeParent.insertBefore(newSection, repeaterTemplate);
clearAndUpdatePageLayout(doc, layout);
int currentPage = layout.getEndPageIndex(insertedNode);

[Note : repeaterTemplate is structuredDocumentTag]
at the current page in aspose java, I am getting an exception Caused by: java.lang.IllegalStateException: This instance is not attached to a document.
Can any one help to resolve this issue?

@Sri_Harsha Could you please attach your input document and provide full code required to reproduce the problem? We will check the issue and provide you more information.