Hi all, I am facing a problem on locking a node or resource. I am using Jackrabbit from Apache Sling and I have the following code (esp file) to lock a node: <% var session = request.getResourceResolver().adaptTo(Packages.javax.jcr.Session);; var wasLockableNode = currentNode.isNodeType("mix:lockable"); if (!wasLockableNode) { currentNode.addMixin("mix:lockable"); session.save(); } var lockOwner = null; var workspace = session.workspace; var lockManager = workspace.lockManager; var wasLocked = lockManager.isLocked(currentNode.path); var locked = false; if (!wasLocked) { var lock = lockManager.lock(currentNode.path, true, false, 120, lockOwner); lockManager.addLockToken(lock.lockToken); locked = true; } else { var lock = lockManager.getLock(currentNode.path); } session.save(); %> <%= currentNode.title %> is locked: <%= locked %>

Is Locking Supported by Repository <%= session.repository.getDescriptorValue(session.repository.OPTION_LOCKING_SUPPORTED).string %>
Is Locked <%= locked %>
Lock Owner: <%= lock.lockOwner %>
Lock Token: <%= lock.lockToken %>
Is Deep: <%= lock.deep %>
Is Session Scoped: <%= lock.sessionScoped %>
Is Current Session Owning Lock: <%= lock.lockOwningSession %>
Was lockable node: <%= wasLockableNode %>
Was Locked: <%= wasLocked %>
Remaining Seconds for the Lock <%= lock.secondsRemaining %>
Current Lock Tokens: <%= Packages.java.util.Arrays.toString(lockManager.lockTokens) %>

After executing the above script, I find that the node was locked. But if I execute the following script just after executing the previous one, I find that node ia not locked!: <%= currentNode.title %>

<%= currentNode.title %>

Title: <%= currentNode.title %>
Is Locked: <%= currentNode.locked %>

Can anyone help me to find out the problem in my code or give me suggestion on how to implement locking on nodes using Sling? Thanks & Regards.