CoreSession.saveDocumentAsNewVersion don't work on documents that were not yet versioned
When calling this method on a document not yet versioned an exception is thrown by
--> generateVersionLabelFor()
---> getVersionsForDocument()
---> doc.getVersions()
because it tries to access the versionHistory node for this document and the node doesn't exists
If you manually make a checkout on the doc (create a new version) the the method will work correctly