I'm trying to create a node and then adding two versions to it. Code goes like this:ChildAssociationRef childAssoc = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CONTENT, properties);
NodeRef newNode = childAssoc.getChildRef();
then adding some content to it:ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
writer.setMimetype(mimetype);
writer.putContent(stream);
Later I'm fetching that same node:NodeRef node = nodeService.getChildByName(parent, ContentModel.ASSOC_CONTAINS, name);
and adding a versionversionService.createVersion(node, null);
and some new contentContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
writer.setMimetype(mimetype);
writer.putContent(stream);
All goes well by here.But when I'm versioning for second time problems occur. I fetch the same node with same call to NodeService.getChildByName, node is found but on calling VersionService.createVersion (with same params) I get exception:
Exception in thread "main" org.alfresco.service.cmr.version.VersionServiceException: 02110001 The current version label of the node does not exist in the version history.
at org.alfresco.repo.version.Version2ServiceImpl.createVersion(Version2ServiceImpl.java:289)
at org.alfresco.repo.version.Version2ServiceImpl.createVersion(Version2ServiceImpl.java:139)
All this code is happening in same transaction.Can someone point to me what I'm doing wrong?Thank you.