Are you checking out the document node before you check on its version history? If not, that might cause the problem. Also, if you're removing the document node, you probably have to check out its parent. -Brian On 4/3/07, Lubos and Alena Pochman wrote: > > I would like to implement rollback function for the versioned node. If > node > has only one version, the node itself is removed. If there is more then > one > version > of the node, the root (top, head) node is removed. I tried v.remove() or > history.removeVersion(v.getName()), but both fail with exception: > > javax.jcr.nodetype.ConstraintViolationException: > > /jcr:system/jcr:versionStorage/23/4c/e0/234ce0e4-4a6a-435c-a4b4-7a8e3fe4f2cf/jcr:rootVersion: > cannot remove a protected node > > Here is the code: > > VersionHistory history = document.getVersionHistory(); > VersionIterator ito = history.getAllVersions(); > if (ito.hasNext()) { > Version v = ito.nextVersion(); // Top version > if (ito.hasNext()) > v.remove(); > else > document.remove(); > session.save(); > } > > > My question is, is it possible or do I have to use workaround like create > new version from version head-1 (create new version) and then remove the > original root version and the original head-1 version? > > Thanks, Lubos >