Here is the code:
P para = factory.createP();
R run = factory.createR();
Text text = factory.createText();
text.setValue( " abc " );
run.getContent().add( text );
para.getContent().add( run );
wordMLPack.getMainDocumentPart().add( para );
Here is the docx generated:
The heading and trailing spaces are all missing.