jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nakedi Koketso Mabusela" <koke...@gmail.com>
Subject StaleItemStateException on ProperyImpl.remove()
Date Tue, 06 Nov 2007 12:14:39 GMT
Hi

When we update a Property on a  javax.jcr.Node we remove any dirty indexed
properties by looping though the PropertyIterator.

while (iter.hasNext()) {
      Property property = iter.nextProperty();
      if
(!RepositoryObjectStoreImpl.namespacePrefixPropertyFilter.accept(property)
&& ! JcrCallbackPersist.STATIC_PROPERTIES.contains(property.getName())) {
        property.remove();
      }
    }

On each Property we execute the remove() method, it works fine until we
introduce JTA transactions. Jackrabbit falls over in :
org.apache.jackrabbit.core.state.SharedItemStateManager.Update.begin(604)

 if (state.isStale()) {
                        boolean merged = false;
                        if (state.isNode()) {
                            NodeStateMerger.MergeContext context =
                                    new NodeStateMerger.MergeContext() {
                                        public boolean isAdded(ItemId id) {
                                            try {
                                                ItemState is = local.get
(id);
                                                return is != null
                                                        && is.getStatus() ==
ItemState.STATUS_NEW;
                                            } catch
(NoSuchItemStateException e) {
                                                return false;
                                            }
                                        }

                                        public boolean isDeleted(ItemId id)
{
                                            return local.deleted(id);
                                        }
                                    };

                            merged = NodeStateMerger.merge((NodeState)
state, context);
                        }
                        if (!merged) {
                            String msg = state.getId() + " has been modified
externally";
                            log.debug(msg);
                            throw new StaleItemStateException(msg);
                        }
                        // merge succeeded, fall through
                    }


It looks as if the state becomes stale on the second update of the property
node, however the "state.isNode()" returns false. I assume that we are not
allowed to update properties this way. But we need to clean up our
properties as we don't want phantom properties sitting in the system and
never been used.

This problem only happens when we are running in a transaction,  how do we
go about this. We are considering changing the Jackrabbit code , we just
want input from anyone as to why there is only a NodeStateMerger and no
PropertyStateMerger.


Thanks
Koketso

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message