Edit: I know what a NullPointerException is, the problem is, that docx4j don't finds any elements in the Paragraph Node.
I'm trying to get the first element of the Text Class in a paragraph.
ClassFinder finder = new ClassFinder(P.class);
new TraversalUtil(model.getWordMLPackage().getMainDocumentPart(),
finder);
finder.results.stream().forEach(
elem -> {
ClassFinder findfirsttext = new ClassFinder(Text.class);
new TraversalUtil(elem, findfirsttext);
Text tt=((Text)findfirsttext.results.get(0));
System.out.println("asdf"+tt.getValue());
});
but
Text tt=((Text)findfirsttext.results.get(0));
always results in a NullPointerException. Because the util doesn't find text elements in the Paragraph.
Since I'm parsing a valid document every Paragraph should contain at least one Text element.