jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torgeir Veimo <torg...@pobox.com>
Subject "Unable to lock node. Node has pending changes: /counter"
Date Mon, 19 Jun 2006 12:17:20 GMT
I get this with the following code;

/* setup, run only once */
            
Node root = session.getRootNode();
Node counter = null;
try {
    counter = (Node) session.getItem("/counter");
} catch (javax.jcr.RepositoryException re) {
    log.debug("repository is empty, setting up default nodes");
    counter = null;
} 
if (counter == null) {
    counter = root.addNode("counter");
    counter.addMixin("mix:lockable");
    counter.setProperty("value", 0);
    session.save();
}

/* sequence fetcher */
public int generateNewResourceId()
    throws UnsupportedOperationException {
        
        try {
            Node counter = (Node) session.getItem("/counter");
            long nextValue = ((Long) new Locked() {
                protected Object run(Node counter) throws
javax.jcr.RepositoryException {
                    Property seqProp = counter.getProperty("value");
                    long value = seqProp.getLong();
                    seqProp.setValue(++value);
                    seqProp.save();
                    return new Long(value);
                }
            }.with(counter, false)).longValue();
            log.debug("sequence value: " + nextValue);
            
        } catch (Exception e) {
            log.error("unable to get new resource id; ", e);
        }
        return -1;
    }

All this is with derby DB, jackrabbit 1.01, and the Locked.java code
from current svn (as of today).

Any clues why I'm getting the following exception?

13:13:19,476 ERROR JackrabbitRepositoryDAO  - unable to get new resource
id;
javax.jcr.InvalidItemStateException: Unable to lock node. Node has
pending changes: /counter
        at org.apache.jackrabbit.core.NodeImpl.lock(NodeImpl.java:3910)
        at org.apache.jackrabbit.util.Locked.tryLock(Locked.java:251)
        at org.apache.jackrabbit.util.Locked.with(Locked.java:145)
        at org.apache.jackrabbit.util.Locked.with(Locked.java:103)
        at
com.netenviron.repository.dao.jackrabbit.JackrabbitRepositoryDAO.generateNewResourceId(JackrabbitRepositoryDAO.java:293)
        at
com.netenviron.repository.RepositoryManager.generateNewResourceId(RepositoryManager.java:164)
        at com.netenviron.repository.Resource.<init>(Resource.java:58)
        at
com.netenviron.repository.dao.jackrabbit.JackrabbitRepositoryDAO.getResource(JackrabbitRepositoryDAO.java:521)


-- 
Torgeir Veimo <torgeir@pobox.com>


Mime
View raw message