In my case, it was caused by concurrent access from different threads to the same session. This is not supported as warned by the spec. I fixed that, but my repository was already corrupted. I patched NodeImpl.java as follows, but I think this change is dangerous, that's why I used it for a while and then reverted to the original version:

--- NodeImpl.java       (revision 379662)
+++ NodeImpl.java       (working copy)
@@ -650,7 +650,11 @@
             thisState.removePropertyName(propName);
             // remove property
PropertyId propId = new PropertyId(thisState.getNodeId(), propName);
-            itemMgr.getItem(propId).setRemoved();
+            try {
+                itemMgr.getItem(propId).setRemoved();
+            } catch (ItemNotFoundException ne) {
+                // ignore it, node may be corrupted
+            }
         }

         // finally remove this node

Cheers,

Carlos

Martin Koci wrote:
Hello Carlos,

do you know series of steps which lead to corrupted node? My code was
pretty simple, no concurrent access, no special operations but
repository is corrupted. I agree with you opinion than jackrabbit should
delete everything left despite inconsistencies.
How did you solve this problem?

Thanks

Martin

Carlos Villegas píše v St 21. 06. 2006 v 09:47 +0900:
I reported this before. The node is corrupted. In my case it looked like the item was defined in some internal data structure of its parent but the item itself didn't exist. Thus jackrabbit internal state is inconsistent and in some parts of the code it tries to create some of these non existent objects; but it fails because of the same inconsistency. I suggested that when deleting an item, jackrabbit should deal with these inconsistencies and delete whatever is left. But the answer was that the inconsistent state shouldn't have happened in the first place :-(. Which, of course, doesn't solve the problem when I already have a corrupted node and want to delete it or repair it.

Carlos

Martin Koci wrote:
Thanks for your answer.

Unfortunately my problem is not reproducible  with a test. I'm using
repository from production environment and that problem appears only
with that repository.

Probably repository is corrupted but this should never happen. I've
added method for removing problematic node but it leads to similar
exception:
javax.jcr.ItemNotFoundException: a156b553-accf-4137-85cb-93ed24d4c8d4
        at
org.apache.jackrabbit.core.ItemManager.createItemInstance(ItemManager.java:465)
        at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:321)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:661)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:662)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:662)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:662)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:662)
        at org.apache.jackrabbit.core.NodeImpl.onRemove(NodeImpl.java:662)
        at
org.apache.jackrabbit.core.NodeImpl.removeChildNode(NodeImpl.java:626)
        at
org.apache.jackrabbit.core.ItemImpl.internalRemove(ItemImpl.java:867)
        at org.apache.jackrabbit.core.ItemImpl.remove(ItemImpl.java:1053)
        at
cz.aura.cms.preferences.impl.PreferencesServiceImpl.deleteUserPreferenceNode(PreferencesServiceImpl.java:271)

Is there any chance to remove problematic nodes? And I don't understand
why item.remove() calls ItemManager.createItemInstance as shown in stack
trace above.
Thanks for any help
Martin



Reply via email to