In this code i remove and replace the text ((ContentAccessor)toReplace.getParent()).getContent().remove(toReplace); this point it reads to be null .
package com.nitspl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.wml.ContentAccessor;
import org.docx4j.wml.P;
import org.docx4j.wml.Tbl;
import org.docx4j.wml.Text;
import org.docx4j.wml.Tr;
public class WordDocxToJava {
private static WordprocessingMLPackage getTemplate(String name) throws Docx4JException, FileNotFoundException {
name ="C:\\Users\\nitspl\\Desktop\\template001.docx";
WordprocessingMLPackage template ...