WEB-2996 - fix NPE when the document is not initialized