You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by SalmasCM <sa...@criticalmass.com> on 2009/05/03 05:36:18 UTC
modified externally: node / when deleting node
I have been trying for weeks to get things working in my application and am
not making any progress.
I don't believe my use case is very unusual and I am hoping that you will be
able to help me.
1. I have a lot of legacy data that I load in using the XML import feature.
Each section is loaded under it's own top level node. The top level nodes
live directly under root.
2. I have 2 workspaces , preview and default. Changes and data loads happen
in preview and are cloned/merged into default.
Everything works if I bulk load the data with the XML import once but falls
apart if I load a all the sections into preview and then clone to default
and then later wish to reload a node with the XML import.
I am unable to reload since it thinks it's a new node so if I reload for
example employees then it creates employees[1] which is not what I want.
I have then 2 options.
1. to force it to recognize the top node as the same node as previously
loaded, to do this I would have to indicate the UUID for the top node.
However, I have no idea how to make the UUID in the XML data file the same
as it would create when reloading?
2. So I tried to delete the node from both preview and default workspaces
before loading. I ran into many issues and finally succeeded in reloading
the data. However, I ran into issues when I modify any data in preview.
I get
Item cannot be saved because it has been modified externally: node /
javax.jcr.InvalidItemStateException: Item cannot be saved because it has
been modified externally: node /
This is the sequence of events.
1. load data using the XML loading under topNodeA in preview workspace
2. I modify some of the data under topNodeA in preview workspace.
3. I save the session etc.
4. I clone the topNodeA and its subtree to the default space.
4. I stop my application server and restart.
5. I get a new session into the preview workspace
6. I try to delete topNodeA in the preview workspace and then I get the
above error.
However, I do NOT receive this error when I do the following (do not get out
of the existing session for that workspace and then subsequently get a new
one but instead remain in the same session for the delete)
1. load data using the XML loading under topNodeA in preview workspace
2. I modify some of the data under topNodeA in preview workspace.
3. I save the session etc.
4. I clone the topNodeA and its subtree to the default space.
5. I try to delete topNodeA in the preview workspace and then I DO NOT get
the above error.
I lock the node while making changes like so:
/**
*
* @param nodeToSet
* The node in which to set the property.
* @param attribute
* @param value
*/
public static boolean saveAttribute(Node nodeToSet, String attribute,
Object value) {
boolean success = false;
if ((nodeToSet != null) && (attribute != null) && (value != null)) {
try {
synchronized (nodeToSet) {
boolean iLockedThis=false;
if (!nodeToSet.isLocked()) {
nodeToSet.addMixin("mix:lockable");
session.save();
nodeToSet.lock(true, true);
iLockedThis=true;
}
if (value instanceof InputStream) {
nodeToSet.setProperty(attribute, (InputStream)
value);
try {
((InputStream) value).close();
} catch (IOException e) {
getInstance().logger.error("IOException
in:saveAttribute " + e);
}
success = true;
} else if (value instanceof Calendar) {
nodeToSet.setProperty(attribute, (Calendar) value);
success = true;
} else if (value instanceof String) {
String stringToSet = (String) value;
nodeToSet.setProperty(attribute, stringToSet);
success = true;
} else if (value instanceof Long) {
nodeToSet.setProperty(attribute, ((Long)
value).longValue());
success = true;
} else if (value instanceof Integer) {
nodeToSet.setProperty(attribute, ((Integer)
value).longValue());
success = true;
} else if (value instanceof Double) {
nodeToSet.setProperty(attribute, ((Double)
value).doubleValue());
success = true;
} else if (value instanceof Boolean) {
nodeToSet.setProperty(attribute, ((Boolean)
value).booleanValue());
success = true;
}
if (iLockedThis) {
session.save();
nodeToSet.unlock();
}
}
} catch (final javax.jcr.ValueFormatException e) {
getInstance().logger.error("ValueFormatException
in:saveAttribute " + e);
} catch (final javax.jcr.version.VersionException e) {
getInstance().logger.error("VersionException
in:saveAttribute " + e);
} catch (final javax.jcr.lock.LockException e) {
getInstance().logger.error("LockException in:saveAttribute "
+ e);
} catch (final javax.jcr.nodetype.ConstraintViolationException
e) {
getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
in:saveAttribute " + e);
} catch (final javax.jcr.RepositoryException e) {
getInstance().logger.error("RepositoryException
in:saveAttribute " + e);
}
}
return success;
}
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Alexander Klimetschek <ak...@day.com>.
On Sun, May 3, 2009 at 5:36 AM, SalmasCM <sa...@criticalmass.com> wrote:
> I get
>
> Item cannot be saved because it has been modified externally: node /
> javax.jcr.InvalidItemStateException: Item cannot be saved because it has
> been modified externally: node /
>
> This is the sequence of events.
>
> 1. load data using the XML loading under topNodeA in preview workspace
> 2. I modify some of the data under topNodeA in preview workspace.
> 3. I save the session etc.
> 4. I clone the topNodeA and its subtree to the default space.
> 4. I stop my application server and restart.
> 5. I get a new session into the preview workspace
> 6. I try to delete topNodeA in the preview workspace and then I get the
> above error.
I don't know much about the clone/merge implementation in Jackrabbit
and therefore have no idea what might be the reason for this problem,
but nevertheless it very much looks like a bug to me. Getting a fresh
new session and then deleting a node from it (5 and 6) without any
other concurrent changes should not produce an InvalidItemStateEx in
any case. Could you report a JIRA issue?
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Thu, May 7, 2009 at 6:26 AM, SalmasCM <sa...@criticalmass.com> wrote:
>
> Guys:
>
> I finally got rid of this exception. The solution was to flip the
> workspaces. I was loading the XML data into the preview ws and cloning it to
> default. However, loading into default and flipping to preview works. Why is
> this?
that's impossible to tell without analysing your application/setup.
> It sounds like a bug or is it by design?
it's certainly not by design ;)
cheers
stefan
>
> Regards
>
> SalmasCM wrote:
>>
>> I also forgot to mention, I can see that it's the top node in the XML
>> import file that is corrupted. It no longer knows its path or its name.
>> failed to resolve name of 813c0297-0a61-41a8-a80a-e90d4d9cd113. Is it ok
>> to be cloning data imported via XML?
>>
>>
>>
>> SalmasCM wrote:
>>>
>>> Stefan:
>>>
>>> I do have a clustered environment. Not only this but my application is
>>> running in BEA Weblogic which tends to spawn a variety of threads. What
>>> do you mean when you say "one session/thread"? I am synchronizing and
>>> locking.
>>> Could you let me know if it is possible to use Jackrabbit in an
>>> application server environment and perhaps a small example of how I
>>> should be synchronizing and locking?
>>> Right now my code looks like this:
>>>
>>>
>>> String topName =
>>> DAOFactory.getInstance().getTopLevelNodeNameForType(type);
>>> removeTopLevelNode(topName);
>>> Session preview =
>>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
>>> previewRoot = preview.getRootNode();
>>> // JCRUtil.getInstance().lockNode(previewRoot, preview);
>>> dataLocation = EnvironmentUtil.getDataLoadDir();
>>> xmlDataLocation = dataLocation + "xml/";
>>> String fileName = xmlDataLocation + topName + ".xml";
>>> logger.info("loading " + fileName);
>>> InputStream stream = CommonUtil.getFile(fileName);
>>> preview.getWorkspace().importXML("/", stream,
>>> ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
>>> preview.save();
>>>
>>> Node nodeToLock = previewRoot.getNode(topName);
>>> synchronized (nodeToLock) {
>>> JCRUtil.getInstance().lockNode(nodeToLock, preview);
>>> Session prod =
>>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
>>> prod.save();
>>>
>>> prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
>>> topName, "/" + topName, true);
>>> prod.save();
>>> JCRUtil.getInstance().unlockNode(nodeToLock);
>>> preview.logout();
>>> prod.logout();
>>> }
>>>
>>> public void lockNode(Node node, Session session) {
>>>
>>> try {
>>> String nodeWSName =
>>> node.getSession().getWorkspace().getName();
>>> String sessionWSName = session.getWorkspace().getName();
>>> logLockPath(node);
>>> if (sessionWSName.equals(nodeWSName)) {
>>> if (node != null && session != null && !node.isLocked())
>>> {
>>> node.addMixin(LOCKABLE_MIXIN);
>>> node.getSession().save();
>>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>>> node.lock(false, true);
>>> if (node.isLocked()) {
>>> break;
>>> }
>>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>>> }
>>> node.getSession().save();
>>> if (!node.isLocked()) {
>>> throw new LockException("Cannot grab lock for
>>> node ");
>>> }
>>> }
>>> } else {
>>> getInstance().logger.error("MISMATCHED WORKSPACE!!!:
>>> node=" +
>>> nodeWSName + " sessionWSName " + sessionWSName);
>>> }
>>> } catch (NoSuchNodeTypeException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:NoSuchNodeTypeException: " + e);
>>> } catch (VersionException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:VersionException: " + e);
>>> } catch (ConstraintViolationException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:ConstraintViolationException: " + e);
>>> } catch (LockException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:LockException: " + e);
>>> } catch (UnsupportedRepositoryOperationException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:UnsupportedRepositoryOperationException: " + e);
>>> } catch (AccessDeniedException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:AccessDeniedException: " + e);
>>> } catch (InvalidItemStateException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:InvalidItemStateException: " + e);
>>> } catch (RepositoryException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:RepositoryException: " + e);
>>> } catch (InterruptedException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:InterruptedException: " + e);
>>> }
>>> }
>>>
>>> public void unlockNode(Node node) {
>>> try {
>>> if (node != null && node.isLocked()) {
>>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>>> node.unlock();
>>> if (!node.isLocked()) {
>>> break;
>>> }
>>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>>> }
>>> if (node.isLocked()) {
>>> throw new LockException("Cannot unlock node ");
>>> }
>>> }
>>> } catch (UnsupportedRepositoryOperationException e) {
>>>
>>> getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
>>> in:unlockNode: " + e);
>>> } catch (LockException e) {
>>> getInstance().logger.error("JCRUtil:LockException
>>> in:unlockNode: " + e);
>>> } catch (AccessDeniedException e) {
>>> getInstance().logger.error("JCRUtil:AccessDeniedException
>>> in:unlockNode: " + e);
>>> } catch (InvalidItemStateException e) {
>>> getInstance().logger.error("JCRUtil:InvalidItemStateException
>>> in:unlockNode: " + e);
>>> } catch (RepositoryException e) {
>>> getInstance().logger.error("JCRUtil:RepositoryException
>>> in:unlockNode: " + e);
>>> } catch (InterruptedException e) {
>>> getInstance().logger.error("JCRUtil:lockNode
>>> in:InterruptedException: " + e);
>>> }
>>> }
>>>
>>> Stefan Guggisberg wrote:
>>>>
>>>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com>
>>>> wrote:
>>>>>
>>>>> The following errors.
>>>>>
>>>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>>> javax.jcr.ItemNotFoundException: failed to build path of
>>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>>> cafebabe-cafe-babe-cafe-babecafebabe
>>>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>>
>>>> assuming jcr sessions are used correctly (i.e. not shared among
>>>> multiple threads)
>>>> you should never see such an exception in a non-clustered jackrabbit
>>>> setup.
>>>>
>>>> it might be a CachingHierarchyManager bug. please create a jira issue
>>>> and provide
>>>> a simple test case for your problem. please also include detailed
>>>> information about
>>>> your setup/environment.
>>>>
>>>> thanks
>>>> stefan
>>>>
>>>>> at
>>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>>>> at
>>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>>> at
>>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>>>> at
>>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>>> at
>>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>>>> at
>>>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>>>> at
>>>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>>>> at
>>>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>>>> at
>>>>> org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>>>> at
>>>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>>>>
>>>>>
>>>>>
>>>>> Alexander Klimetschek wrote:
>>>>>>
>>>>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> The reason I think its the index is because if I:
>>>>>>>
>>>>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>>>>> 2. Clone nodeA to workspace2
>>>>>>> 2. Exit my application.
>>>>>>> 3. Delete nodeA from workspace 1 and 2
>>>>>>> 4. Reload a file in from XML import.
>>>>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>>>>
>>>>>> What errors?
>>>>>>
>>>>>> Regards,
>>>>>> Alex
>>>>>>
>>>>>> --
>>>>>> Alexander Klimetschek
>>>>>> alexander.klimetschek@day.com
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419999.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
Guys:
I finally got rid of this exception. The solution was to flip the
workspaces. I was loading the XML data into the preview ws and cloning it to
default. However, loading into default and flipping to preview works. Why is
this? It sounds like a bug or is it by design?
Regards
SalmasCM wrote:
>
> I also forgot to mention, I can see that it's the top node in the XML
> import file that is corrupted. It no longer knows its path or its name.
> failed to resolve name of 813c0297-0a61-41a8-a80a-e90d4d9cd113. Is it ok
> to be cloning data imported via XML?
>
>
>
> SalmasCM wrote:
>>
>> Stefan:
>>
>> I do have a clustered environment. Not only this but my application is
>> running in BEA Weblogic which tends to spawn a variety of threads. What
>> do you mean when you say "one session/thread"? I am synchronizing and
>> locking.
>> Could you let me know if it is possible to use Jackrabbit in an
>> application server environment and perhaps a small example of how I
>> should be synchronizing and locking?
>> Right now my code looks like this:
>>
>>
>> String topName =
>> DAOFactory.getInstance().getTopLevelNodeNameForType(type);
>> removeTopLevelNode(topName);
>> Session preview =
>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
>> previewRoot = preview.getRootNode();
>> // JCRUtil.getInstance().lockNode(previewRoot, preview);
>> dataLocation = EnvironmentUtil.getDataLoadDir();
>> xmlDataLocation = dataLocation + "xml/";
>> String fileName = xmlDataLocation + topName + ".xml";
>> logger.info("loading " + fileName);
>> InputStream stream = CommonUtil.getFile(fileName);
>> preview.getWorkspace().importXML("/", stream,
>> ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
>> preview.save();
>>
>> Node nodeToLock = previewRoot.getNode(topName);
>> synchronized (nodeToLock) {
>> JCRUtil.getInstance().lockNode(nodeToLock, preview);
>> Session prod =
>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
>> prod.save();
>>
>> prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
>> topName, "/" + topName, true);
>> prod.save();
>> JCRUtil.getInstance().unlockNode(nodeToLock);
>> preview.logout();
>> prod.logout();
>> }
>>
>> public void lockNode(Node node, Session session) {
>>
>> try {
>> String nodeWSName =
>> node.getSession().getWorkspace().getName();
>> String sessionWSName = session.getWorkspace().getName();
>> logLockPath(node);
>> if (sessionWSName.equals(nodeWSName)) {
>> if (node != null && session != null && !node.isLocked())
>> {
>> node.addMixin(LOCKABLE_MIXIN);
>> node.getSession().save();
>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>> node.lock(false, true);
>> if (node.isLocked()) {
>> break;
>> }
>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>> }
>> node.getSession().save();
>> if (!node.isLocked()) {
>> throw new LockException("Cannot grab lock for
>> node ");
>> }
>> }
>> } else {
>> getInstance().logger.error("MISMATCHED WORKSPACE!!!:
>> node=" +
>> nodeWSName + " sessionWSName " + sessionWSName);
>> }
>> } catch (NoSuchNodeTypeException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:NoSuchNodeTypeException: " + e);
>> } catch (VersionException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:VersionException: " + e);
>> } catch (ConstraintViolationException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:ConstraintViolationException: " + e);
>> } catch (LockException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:LockException: " + e);
>> } catch (UnsupportedRepositoryOperationException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:UnsupportedRepositoryOperationException: " + e);
>> } catch (AccessDeniedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:AccessDeniedException: " + e);
>> } catch (InvalidItemStateException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InvalidItemStateException: " + e);
>> } catch (RepositoryException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:RepositoryException: " + e);
>> } catch (InterruptedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InterruptedException: " + e);
>> }
>> }
>>
>> public void unlockNode(Node node) {
>> try {
>> if (node != null && node.isLocked()) {
>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>> node.unlock();
>> if (!node.isLocked()) {
>> break;
>> }
>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>> }
>> if (node.isLocked()) {
>> throw new LockException("Cannot unlock node ");
>> }
>> }
>> } catch (UnsupportedRepositoryOperationException e) {
>>
>> getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
>> in:unlockNode: " + e);
>> } catch (LockException e) {
>> getInstance().logger.error("JCRUtil:LockException
>> in:unlockNode: " + e);
>> } catch (AccessDeniedException e) {
>> getInstance().logger.error("JCRUtil:AccessDeniedException
>> in:unlockNode: " + e);
>> } catch (InvalidItemStateException e) {
>> getInstance().logger.error("JCRUtil:InvalidItemStateException
>> in:unlockNode: " + e);
>> } catch (RepositoryException e) {
>> getInstance().logger.error("JCRUtil:RepositoryException
>> in:unlockNode: " + e);
>> } catch (InterruptedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InterruptedException: " + e);
>> }
>> }
>>
>> Stefan Guggisberg wrote:
>>>
>>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com>
>>> wrote:
>>>>
>>>> The following errors.
>>>>
>>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>> javax.jcr.ItemNotFoundException: failed to build path of
>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>> cafebabe-cafe-babe-cafe-babecafebabe
>>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>
>>> assuming jcr sessions are used correctly (i.e. not shared among
>>> multiple threads)
>>> you should never see such an exception in a non-clustered jackrabbit
>>> setup.
>>>
>>> it might be a CachingHierarchyManager bug. please create a jira issue
>>> and provide
>>> a simple test case for your problem. please also include detailed
>>> information about
>>> your setup/environment.
>>>
>>> thanks
>>> stefan
>>>
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>>> at
>>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>>> at
>>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>>> at
>>>> org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>>> at
>>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>>>
>>>>
>>>>
>>>> Alexander Klimetschek wrote:
>>>>>
>>>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>>>> wrote:
>>>>>>
>>>>>> The reason I think its the index is because if I:
>>>>>>
>>>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>>>> 2. Clone nodeA to workspace2
>>>>>> 2. Exit my application.
>>>>>> 3. Delete nodeA from workspace 1 and 2
>>>>>> 4. Reload a file in from XML import.
>>>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>>>
>>>>> What errors?
>>>>>
>>>>> Regards,
>>>>> Alex
>>>>>
>>>>> --
>>>>> Alexander Klimetschek
>>>>> alexander.klimetschek@day.com
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419999.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Thu, May 7, 2009 at 5:23 AM, SalmasCM <sa...@criticalmass.com> wrote:
>
> I also forgot to mention, I can see that it's the top node in the XML import
> file that is corrupted. It no longer knows its path or its name. failed to
> resolve name of 813c0297-0a61-41a8-a80a-e90d4d9cd113. Is it ok to be cloning
> data imported via XML?
yes
>
>
>
> SalmasCM wrote:
>>
>> Stefan:
>>
>> I do have a clustered environment. Not only this but my application is
>> running in BEA Weblogic which tends to spawn a variety of threads. What do
>> you mean when you say "one session/thread"? I am synchronizing and
>> locking.
>> Could you let me know if it is possible to use Jackrabbit in an
>> application server environment and perhaps a small example of how I should
>> be synchronizing and locking?
>> Right now my code looks like this:
>>
>>
>> String topName =
>> DAOFactory.getInstance().getTopLevelNodeNameForType(type);
>> removeTopLevelNode(topName);
>> Session preview =
>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
>> previewRoot = preview.getRootNode();
>> // JCRUtil.getInstance().lockNode(previewRoot, preview);
>> dataLocation = EnvironmentUtil.getDataLoadDir();
>> xmlDataLocation = dataLocation + "xml/";
>> String fileName = xmlDataLocation + topName + ".xml";
>> logger.info("loading " + fileName);
>> InputStream stream = CommonUtil.getFile(fileName);
>> preview.getWorkspace().importXML("/", stream,
>> ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
>> preview.save();
>>
>> Node nodeToLock = previewRoot.getNode(topName);
>> synchronized (nodeToLock) {
>> JCRUtil.getInstance().lockNode(nodeToLock, preview);
>> Session prod =
>> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
>> prod.save();
>>
>> prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
>> topName, "/" + topName, true);
>> prod.save();
>> JCRUtil.getInstance().unlockNode(nodeToLock);
>> preview.logout();
>> prod.logout();
>> }
>>
>> public void lockNode(Node node, Session session) {
>>
>> try {
>> String nodeWSName =
>> node.getSession().getWorkspace().getName();
>> String sessionWSName = session.getWorkspace().getName();
>> logLockPath(node);
>> if (sessionWSName.equals(nodeWSName)) {
>> if (node != null && session != null && !node.isLocked()) {
>> node.addMixin(LOCKABLE_MIXIN);
>> node.getSession().save();
>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>> node.lock(false, true);
>> if (node.isLocked()) {
>> break;
>> }
>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>> }
>> node.getSession().save();
>> if (!node.isLocked()) {
>> throw new LockException("Cannot grab lock for node
>> ");
>> }
>> }
>> } else {
>> getInstance().logger.error("MISMATCHED WORKSPACE!!!:
>> node=" +
>> nodeWSName + " sessionWSName " + sessionWSName);
>> }
>> } catch (NoSuchNodeTypeException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:NoSuchNodeTypeException: " + e);
>> } catch (VersionException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:VersionException: " + e);
>> } catch (ConstraintViolationException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:ConstraintViolationException: " + e);
>> } catch (LockException e) {
>> getInstance().logger.error("JCRUtil:lockNode in:LockException:
>> " + e);
>> } catch (UnsupportedRepositoryOperationException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:UnsupportedRepositoryOperationException: " + e);
>> } catch (AccessDeniedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:AccessDeniedException: " + e);
>> } catch (InvalidItemStateException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InvalidItemStateException: " + e);
>> } catch (RepositoryException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:RepositoryException: " + e);
>> } catch (InterruptedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InterruptedException: " + e);
>> }
>> }
>>
>> public void unlockNode(Node node) {
>> try {
>> if (node != null && node.isLocked()) {
>> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
>> node.unlock();
>> if (!node.isLocked()) {
>> break;
>> }
>> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
>> }
>> if (node.isLocked()) {
>> throw new LockException("Cannot unlock node ");
>> }
>> }
>> } catch (UnsupportedRepositoryOperationException e) {
>>
>> getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
>> in:unlockNode: " + e);
>> } catch (LockException e) {
>> getInstance().logger.error("JCRUtil:LockException
>> in:unlockNode: " + e);
>> } catch (AccessDeniedException e) {
>> getInstance().logger.error("JCRUtil:AccessDeniedException
>> in:unlockNode: " + e);
>> } catch (InvalidItemStateException e) {
>> getInstance().logger.error("JCRUtil:InvalidItemStateException
>> in:unlockNode: " + e);
>> } catch (RepositoryException e) {
>> getInstance().logger.error("JCRUtil:RepositoryException
>> in:unlockNode: " + e);
>> } catch (InterruptedException e) {
>> getInstance().logger.error("JCRUtil:lockNode
>> in:InterruptedException: " + e);
>> }
>> }
>>
>> Stefan Guggisberg wrote:
>>>
>>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>>>
>>>> The following errors.
>>>>
>>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>> javax.jcr.ItemNotFoundException: failed to build path of
>>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>>> cafebabe-cafe-babe-cafe-babecafebabe
>>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>>
>>> assuming jcr sessions are used correctly (i.e. not shared among
>>> multiple threads)
>>> you should never see such an exception in a non-clustered jackrabbit
>>> setup.
>>>
>>> it might be a CachingHierarchyManager bug. please create a jira issue
>>> and provide
>>> a simple test case for your problem. please also include detailed
>>> information about
>>> your setup/environment.
>>>
>>> thanks
>>> stefan
>>>
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>>> at
>>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>>> at
>>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>>> at
>>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>>> at
>>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>>> at
>>>> org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>>> at
>>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>>>
>>>>
>>>>
>>>> Alexander Klimetschek wrote:
>>>>>
>>>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>>>> wrote:
>>>>>>
>>>>>> The reason I think its the index is because if I:
>>>>>>
>>>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>>>> 2. Clone nodeA to workspace2
>>>>>> 2. Exit my application.
>>>>>> 3. Delete nodeA from workspace 1 and 2
>>>>>> 4. Reload a file in from XML import.
>>>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>>>
>>>>> What errors?
>>>>>
>>>>> Regards,
>>>>> Alex
>>>>>
>>>>> --
>>>>> Alexander Klimetschek
>>>>> alexander.klimetschek@day.com
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419555.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
I also forgot to mention, I can see that it's the top node in the XML import
file that is corrupted. It no longer knows its path or its name. failed to
resolve name of 813c0297-0a61-41a8-a80a-e90d4d9cd113. Is it ok to be cloning
data imported via XML?
SalmasCM wrote:
>
> Stefan:
>
> I do have a clustered environment. Not only this but my application is
> running in BEA Weblogic which tends to spawn a variety of threads. What do
> you mean when you say "one session/thread"? I am synchronizing and
> locking.
> Could you let me know if it is possible to use Jackrabbit in an
> application server environment and perhaps a small example of how I should
> be synchronizing and locking?
> Right now my code looks like this:
>
>
> String topName =
> DAOFactory.getInstance().getTopLevelNodeNameForType(type);
> removeTopLevelNode(topName);
> Session preview =
> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
> previewRoot = preview.getRootNode();
> // JCRUtil.getInstance().lockNode(previewRoot, preview);
> dataLocation = EnvironmentUtil.getDataLoadDir();
> xmlDataLocation = dataLocation + "xml/";
> String fileName = xmlDataLocation + topName + ".xml";
> logger.info("loading " + fileName);
> InputStream stream = CommonUtil.getFile(fileName);
> preview.getWorkspace().importXML("/", stream,
> ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
> preview.save();
>
> Node nodeToLock = previewRoot.getNode(topName);
> synchronized (nodeToLock) {
> JCRUtil.getInstance().lockNode(nodeToLock, preview);
> Session prod =
> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
> prod.save();
>
> prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
> topName, "/" + topName, true);
> prod.save();
> JCRUtil.getInstance().unlockNode(nodeToLock);
> preview.logout();
> prod.logout();
> }
>
> public void lockNode(Node node, Session session) {
>
> try {
> String nodeWSName =
> node.getSession().getWorkspace().getName();
> String sessionWSName = session.getWorkspace().getName();
> logLockPath(node);
> if (sessionWSName.equals(nodeWSName)) {
> if (node != null && session != null && !node.isLocked()) {
> node.addMixin(LOCKABLE_MIXIN);
> node.getSession().save();
> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
> node.lock(false, true);
> if (node.isLocked()) {
> break;
> }
> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
> }
> node.getSession().save();
> if (!node.isLocked()) {
> throw new LockException("Cannot grab lock for node
> ");
> }
> }
> } else {
> getInstance().logger.error("MISMATCHED WORKSPACE!!!:
> node=" +
> nodeWSName + " sessionWSName " + sessionWSName);
> }
> } catch (NoSuchNodeTypeException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:NoSuchNodeTypeException: " + e);
> } catch (VersionException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:VersionException: " + e);
> } catch (ConstraintViolationException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:ConstraintViolationException: " + e);
> } catch (LockException e) {
> getInstance().logger.error("JCRUtil:lockNode in:LockException:
> " + e);
> } catch (UnsupportedRepositoryOperationException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:UnsupportedRepositoryOperationException: " + e);
> } catch (AccessDeniedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:AccessDeniedException: " + e);
> } catch (InvalidItemStateException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InvalidItemStateException: " + e);
> } catch (RepositoryException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:RepositoryException: " + e);
> } catch (InterruptedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InterruptedException: " + e);
> }
> }
>
> public void unlockNode(Node node) {
> try {
> if (node != null && node.isLocked()) {
> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
> node.unlock();
> if (!node.isLocked()) {
> break;
> }
> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
> }
> if (node.isLocked()) {
> throw new LockException("Cannot unlock node ");
> }
> }
> } catch (UnsupportedRepositoryOperationException e) {
>
> getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
> in:unlockNode: " + e);
> } catch (LockException e) {
> getInstance().logger.error("JCRUtil:LockException
> in:unlockNode: " + e);
> } catch (AccessDeniedException e) {
> getInstance().logger.error("JCRUtil:AccessDeniedException
> in:unlockNode: " + e);
> } catch (InvalidItemStateException e) {
> getInstance().logger.error("JCRUtil:InvalidItemStateException
> in:unlockNode: " + e);
> } catch (RepositoryException e) {
> getInstance().logger.error("JCRUtil:RepositoryException
> in:unlockNode: " + e);
> } catch (InterruptedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InterruptedException: " + e);
> }
> }
>
> Stefan Guggisberg wrote:
>>
>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>>
>>> The following errors.
>>>
>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>> javax.jcr.ItemNotFoundException: failed to build path of
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe
>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>
>> assuming jcr sessions are used correctly (i.e. not shared among
>> multiple threads)
>> you should never see such an exception in a non-clustered jackrabbit
>> setup.
>>
>> it might be a CachingHierarchyManager bug. please create a jira issue
>> and provide
>> a simple test case for your problem. please also include detailed
>> information about
>> your setup/environment.
>>
>> thanks
>> stefan
>>
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>> at
>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>> at
>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>> at
>>> org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>> at
>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>>
>>>
>>>
>>> Alexander Klimetschek wrote:
>>>>
>>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>>> wrote:
>>>>>
>>>>> The reason I think its the index is because if I:
>>>>>
>>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>>> 2. Clone nodeA to workspace2
>>>>> 2. Exit my application.
>>>>> 3. Delete nodeA from workspace 1 and 2
>>>>> 4. Reload a file in from XML import.
>>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>>
>>>> What errors?
>>>>
>>>> Regards,
>>>> Alex
>>>>
>>>> --
>>>> Alexander Klimetschek
>>>> alexander.klimetschek@day.com
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419555.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Thu, May 7, 2009 at 11:25 AM, Alexander Klimetschek <ak...@day.com> wrote:
> On Thu, May 7, 2009 at 10:18 AM, Stefan Guggisberg
> <st...@gmail.com> wrote:
>> javax.jcr.Session is thread-safe. see "7.5 Thread-Safety Requirements" in the
>> jsr 170 spec.
>
> I guess you mean javax.jcr.Session is *not* thread-safe. ;-)
doh! of course...;)
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
Re: modified externally: node / when deleting node
Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, May 7, 2009 at 10:18 AM, Stefan Guggisberg
<st...@gmail.com> wrote:
> javax.jcr.Session is thread-safe. see "7.5 Thread-Safety Requirements" in the
> jsr 170 spec.
I guess you mean javax.jcr.Session is *not* thread-safe. ;-)
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Thu, May 7, 2009 at 5:07 AM, SalmasCM <sa...@criticalmass.com> wrote:
>
> Stefan:
>
> I do have a clustered environment. Not only this but my application is
> running in BEA Weblogic which tends to spawn a variety of threads. What do
> you mean when you say "one session/thread"?
javax.jcr.Session is thread-safe. see "7.5 Thread-Safety Requirements" in the
jsr 170 spec.
> I am synchronizing and locking.
> Could you let me know if it is possible to use Jackrabbit in an application
> server environment
absolutely
> and perhaps a small example of how I should be
> synchronizing and locking?
see e.g.
http://wiki.apache.org/jackrabbit/JcrSessionHandling
http://www.nabble.com/Session-Handling-in-WebApplication-tt19386158.html#a19386158
cheers
stefan
> Right now my code looks like this:
>
>
> String topName =
> DAOFactory.getInstance().getTopLevelNodeNameForType(type);
> removeTopLevelNode(topName);
> Session preview =
> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
> previewRoot = preview.getRootNode();
> // JCRUtil.getInstance().lockNode(previewRoot, preview);
> dataLocation = EnvironmentUtil.getDataLoadDir();
> xmlDataLocation = dataLocation + "xml/";
> String fileName = xmlDataLocation + topName + ".xml";
> logger.info("loading " + fileName);
> InputStream stream = CommonUtil.getFile(fileName);
> preview.getWorkspace().importXML("/", stream,
> ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
> preview.save();
>
> Node nodeToLock = previewRoot.getNode(topName);
> synchronized (nodeToLock) {
> JCRUtil.getInstance().lockNode(nodeToLock, preview);
> Session prod =
> JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
> prod.save();
>
> prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
> topName, "/" + topName, true);
> prod.save();
> JCRUtil.getInstance().unlockNode(nodeToLock);
> preview.logout();
> prod.logout();
> }
>
> public void lockNode(Node node, Session session) {
>
> try {
> String nodeWSName = node.getSession().getWorkspace().getName();
> String sessionWSName = session.getWorkspace().getName();
> logLockPath(node);
> if (sessionWSName.equals(nodeWSName)) {
> if (node != null && session != null && !node.isLocked()) {
> node.addMixin(LOCKABLE_MIXIN);
> node.getSession().save();
> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
> node.lock(false, true);
> if (node.isLocked()) {
> break;
> }
> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
> }
> node.getSession().save();
> if (!node.isLocked()) {
> throw new LockException("Cannot grab lock for node
> ");
> }
> }
> } else {
> getInstance().logger.error("MISMATCHED WORKSPACE!!!: node="
> +
> nodeWSName + " sessionWSName " + sessionWSName);
> }
> } catch (NoSuchNodeTypeException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:NoSuchNodeTypeException: " + e);
> } catch (VersionException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:VersionException: " + e);
> } catch (ConstraintViolationException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:ConstraintViolationException: " + e);
> } catch (LockException e) {
> getInstance().logger.error("JCRUtil:lockNode in:LockException: "
> + e);
> } catch (UnsupportedRepositoryOperationException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:UnsupportedRepositoryOperationException: " + e);
> } catch (AccessDeniedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:AccessDeniedException: " + e);
> } catch (InvalidItemStateException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InvalidItemStateException: " + e);
> } catch (RepositoryException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:RepositoryException: " + e);
> } catch (InterruptedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InterruptedException: " + e);
> }
> }
>
> public void unlockNode(Node node) {
> try {
> if (node != null && node.isLocked()) {
> for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
> node.unlock();
> if (!node.isLocked()) {
> break;
> }
> Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
> }
> if (node.isLocked()) {
> throw new LockException("Cannot unlock node ");
> }
> }
> } catch (UnsupportedRepositoryOperationException e) {
>
> getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
> in:unlockNode: " + e);
> } catch (LockException e) {
> getInstance().logger.error("JCRUtil:LockException in:unlockNode:
> " + e);
> } catch (AccessDeniedException e) {
> getInstance().logger.error("JCRUtil:AccessDeniedException
> in:unlockNode: " + e);
> } catch (InvalidItemStateException e) {
> getInstance().logger.error("JCRUtil:InvalidItemStateException
> in:unlockNode: " + e);
> } catch (RepositoryException e) {
> getInstance().logger.error("JCRUtil:RepositoryException
> in:unlockNode: " + e);
> } catch (InterruptedException e) {
> getInstance().logger.error("JCRUtil:lockNode
> in:InterruptedException: " + e);
> }
> }
>
> Stefan Guggisberg wrote:
>>
>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>>
>>> The following errors.
>>>
>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>> javax.jcr.ItemNotFoundException: failed to build path of
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe
>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>
>> assuming jcr sessions are used correctly (i.e. not shared among
>> multiple threads)
>> you should never see such an exception in a non-clustered jackrabbit
>> setup.
>>
>> it might be a CachingHierarchyManager bug. please create a jira issue
>> and provide
>> a simple test case for your problem. please also include detailed
>> information about
>> your setup/environment.
>>
>> thanks
>> stefan
>>
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>> at
>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>> at
>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>> at
>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>>
>>>
>>>
>>> Alexander Klimetschek wrote:
>>>>
>>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>>> wrote:
>>>>>
>>>>> The reason I think its the index is because if I:
>>>>>
>>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>>> 2. Clone nodeA to workspace2
>>>>> 2. Exit my application.
>>>>> 3. Delete nodeA from workspace 1 and 2
>>>>> 4. Reload a file in from XML import.
>>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>>
>>>> What errors?
>>>>
>>>> Regards,
>>>> Alex
>>>>
>>>> --
>>>> Alexander Klimetschek
>>>> alexander.klimetschek@day.com
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419439.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
Stefan:
I do have a clustered environment. Not only this but my application is
running in BEA Weblogic which tends to spawn a variety of threads. What do
you mean when you say "one session/thread"? I am synchronizing and locking.
Could you let me know if it is possible to use Jackrabbit in an application
server environment and perhaps a small example of how I should be
synchronizing and locking?
Right now my code looks like this:
String topName =
DAOFactory.getInstance().getTopLevelNodeNameForType(type);
removeTopLevelNode(topName);
Session preview =
JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PREVIEW_WORKSPACE);
previewRoot = preview.getRootNode();
// JCRUtil.getInstance().lockNode(previewRoot, preview);
dataLocation = EnvironmentUtil.getDataLoadDir();
xmlDataLocation = dataLocation + "xml/";
String fileName = xmlDataLocation + topName + ".xml";
logger.info("loading " + fileName);
InputStream stream = CommonUtil.getFile(fileName);
preview.getWorkspace().importXML("/", stream,
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
preview.save();
Node nodeToLock = previewRoot.getNode(topName);
synchronized (nodeToLock) {
JCRUtil.getInstance().lockNode(nodeToLock, preview);
Session prod =
JCRConnectionUtil.getInstance().getNewSession(ConnectionManager.PRODUCTION_WORKSPACE);
prod.save();
prod.getWorkspace().clone(ConnectionManager.PREVIEW_WORKSPACE, "/" +
topName, "/" + topName, true);
prod.save();
JCRUtil.getInstance().unlockNode(nodeToLock);
preview.logout();
prod.logout();
}
public void lockNode(Node node, Session session) {
try {
String nodeWSName = node.getSession().getWorkspace().getName();
String sessionWSName = session.getWorkspace().getName();
logLockPath(node);
if (sessionWSName.equals(nodeWSName)) {
if (node != null && session != null && !node.isLocked()) {
node.addMixin(LOCKABLE_MIXIN);
node.getSession().save();
for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
node.lock(false, true);
if (node.isLocked()) {
break;
}
Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
}
node.getSession().save();
if (!node.isLocked()) {
throw new LockException("Cannot grab lock for node
");
}
}
} else {
getInstance().logger.error("MISMATCHED WORKSPACE!!!: node="
+
nodeWSName + " sessionWSName " + sessionWSName);
}
} catch (NoSuchNodeTypeException e) {
getInstance().logger.error("JCRUtil:lockNode
in:NoSuchNodeTypeException: " + e);
} catch (VersionException e) {
getInstance().logger.error("JCRUtil:lockNode
in:VersionException: " + e);
} catch (ConstraintViolationException e) {
getInstance().logger.error("JCRUtil:lockNode
in:ConstraintViolationException: " + e);
} catch (LockException e) {
getInstance().logger.error("JCRUtil:lockNode in:LockException: "
+ e);
} catch (UnsupportedRepositoryOperationException e) {
getInstance().logger.error("JCRUtil:lockNode
in:UnsupportedRepositoryOperationException: " + e);
} catch (AccessDeniedException e) {
getInstance().logger.error("JCRUtil:lockNode
in:AccessDeniedException: " + e);
} catch (InvalidItemStateException e) {
getInstance().logger.error("JCRUtil:lockNode
in:InvalidItemStateException: " + e);
} catch (RepositoryException e) {
getInstance().logger.error("JCRUtil:lockNode
in:RepositoryException: " + e);
} catch (InterruptedException e) {
getInstance().logger.error("JCRUtil:lockNode
in:InterruptedException: " + e);
}
}
public void unlockNode(Node node) {
try {
if (node != null && node.isLocked()) {
for (int i = 0; i < MAX_LOCK_UNLOCK_TRIES; i++) {
node.unlock();
if (!node.isLocked()) {
break;
}
Thread.sleep(LOCK_UNLOCK_TRIES_SLEEP_INTERVAL);
}
if (node.isLocked()) {
throw new LockException("Cannot unlock node ");
}
}
} catch (UnsupportedRepositoryOperationException e) {
getInstance().logger.error("JCRUtil:UnsupportedRepositoryOperationException
in:unlockNode: " + e);
} catch (LockException e) {
getInstance().logger.error("JCRUtil:LockException in:unlockNode:
" + e);
} catch (AccessDeniedException e) {
getInstance().logger.error("JCRUtil:AccessDeniedException
in:unlockNode: " + e);
} catch (InvalidItemStateException e) {
getInstance().logger.error("JCRUtil:InvalidItemStateException
in:unlockNode: " + e);
} catch (RepositoryException e) {
getInstance().logger.error("JCRUtil:RepositoryException
in:unlockNode: " + e);
} catch (InterruptedException e) {
getInstance().logger.error("JCRUtil:lockNode
in:InterruptedException: " + e);
}
}
Stefan Guggisberg wrote:
>
> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>
>> The following errors.
>>
>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>> javax.jcr.ItemNotFoundException: failed to build path of
>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>> cafebabe-cafe-babe-cafe-babecafebabe
>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>
> assuming jcr sessions are used correctly (i.e. not shared among
> multiple threads)
> you should never see such an exception in a non-clustered jackrabbit
> setup.
>
> it might be a CachingHierarchyManager bug. please create a jira issue
> and provide
> a simple test case for your problem. please also include detailed
> information about
> your setup/environment.
>
> thanks
> stefan
>
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>> at
>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>> at
>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>> at
>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>
>>
>>
>> Alexander Klimetschek wrote:
>>>
>>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com>
>>> wrote:
>>>>
>>>> The reason I think its the index is because if I:
>>>>
>>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>>> 2. Clone nodeA to workspace2
>>>> 2. Exit my application.
>>>> 3. Delete nodeA from workspace 1 and 2
>>>> 4. Reload a file in from XML import.
>>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>>
>>> What errors?
>>>
>>> Regards,
>>> Alex
>>>
>>> --
>>> Alexander Klimetschek
>>> alexander.klimetschek@day.com
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23419439.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>
> The following errors.
>
> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
> dd740ff8-5108-40f2-9036-b6c769c86bd5
> javax.jcr.ItemNotFoundException: failed to build path of
> dd740ff8-5108-40f2-9036-b6c769c86bd5: cafebabe-cafe-babe-cafe-babecafebabe
> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
assuming jcr sessions are used correctly (i.e. not shared among
multiple threads)
you should never see such an exception in a non-clustered jackrabbit setup.
it might be a CachingHierarchyManager bug. please create a jira issue
and provide
a simple test case for your problem. please also include detailed
information about
your setup/environment.
thanks
stefan
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
> at
> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
> at
> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
> at
> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>
>
>
> Alexander Klimetschek wrote:
>>
>> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>>
>>> The reason I think its the index is because if I:
>>>
>>> 1. Load a file in from XML import under /nodeA in workspace 1.
>>> 2. Clone nodeA to workspace2
>>> 2. Exit my application.
>>> 3. Delete nodeA from workspace 1 and 2
>>> 4. Reload a file in from XML import.
>>> 5. Do a XPATH query for a node in the imported data I get errors.
>>
>> What errors?
>>
>> Regards,
>> Alex
>>
>> --
>> Alexander Klimetschek
>> alexander.klimetschek@day.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
Hi Alexander:
I've gotten past the issue with things being different after server start.
This turned out to be because I had two sessions into one of the workspaces
at start time. However, I still have my original issue.
I cannot create a node /nodeA and then clone it to the second workspace and
then delete both of them in order to reload the XML. They seem to refer to
each other and I get item not found exceptions no matter which order I
delete them in. Is it possible for me to do the above?
If not can I do something to make the XML import not create /nodeA[1] when I
reload data but instead replace /nodeA?
SalmasCM wrote:
>
> hi Alexander:
>
> You're right. the query returns nodes all right. I run
> //document[@type="7" and @published="true" and @active="true"] order by
> @position
>
> and get nodes back correctly
>
> its getPath that fails later down the line.
>
>
> Alexander Klimetschek wrote:
>>
>> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>>
>>> The following errors.
>>>
>>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>>> javax.jcr.ItemNotFoundException: failed to build path of
>>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>>> cafebabe-cafe-babe-cafe-babecafebabe
>>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>>> at
>>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>>> at
>>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>>> at
>>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>>> at
>>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>>> at
>>> org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>>> at
>>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>>
>> Just to be sure, this stacktrace does not come from a query, but from
>> a getPath() call. How does the query stacktrace look like?
>>
>> Regards,
>> Alex
>>
>> --
>> Alexander Klimetschek
>> alexander.klimetschek@day.com
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23399880.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
hi Alexander:
You're right. the query returns nodes all right. I run
//document[@type="7" and @published="true" and @active="true"] order by
@position
and get nodes back correctly
its getPath that fails later down the line.
Alexander Klimetschek wrote:
>
> On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>
>> The following errors.
>>
>> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
>> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
>> dd740ff8-5108-40f2-9036-b6c769c86bd5
>> javax.jcr.ItemNotFoundException: failed to build path of
>> dd740ff8-5108-40f2-9036-b6c769c86bd5:
>> cafebabe-cafe-babe-cafe-babecafebabe
>> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
>> at
>> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
>> at
>> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
>> at
>> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
>> at
>> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
>> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
>> at
>> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>
> Just to be sure, this stacktrace does not come from a query, but from
> a getPath() call. How does the query stacktrace look like?
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23391737.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, May 5, 2009 at 4:56 PM, SalmasCM <sa...@criticalmass.com> wrote:
>
> The following errors.
>
> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
> dd740ff8-5108-40f2-9036-b6c769c86bd5
> javax.jcr.ItemNotFoundException: failed to build path of
> dd740ff8-5108-40f2-9036-b6c769c86bd5: cafebabe-cafe-babe-cafe-babecafebabe
> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
> at
> org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
> at
> org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
> at
> com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
Just to be sure, this stacktrace does not come from a query, but from
a getPath() call. How does the query stacktrace look like?
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
The following errors.
failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
dd740ff8-5108-40f2-9036-b6c769c86bd5
javax.jcr.ItemNotFoundException: failed to build path of
dd740ff8-5108-40f2-9036-b6c769c86bd5: cafebabe-cafe-babe-cafe-babecafebabe
has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
at
org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
at
org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
at
org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
at
org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
at
org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
at
org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
at
org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
at
org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
at
com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
Alexander Klimetschek wrote:
>
> On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com> wrote:
>>
>> The reason I think its the index is because if I:
>>
>> 1. Load a file in from XML import under /nodeA in workspace 1.
>> 2. Clone nodeA to workspace2
>> 2. Exit my application.
>> 3. Delete nodeA from workspace 1 and 2
>> 4. Reload a file in from XML import.
>> 5. Do a XPATH query for a node in the imported data I get errors.
>
> What errors?
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23389174.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, May 5, 2009 at 4:08 PM, SalmasCM <sa...@criticalmass.com> wrote:
>
> The reason I think its the index is because if I:
>
> 1. Load a file in from XML import under /nodeA in workspace 1.
> 2. Clone nodeA to workspace2
> 2. Exit my application.
> 3. Delete nodeA from workspace 1 and 2
> 4. Reload a file in from XML import.
> 5. Do a XPATH query for a node in the imported data I get errors.
What errors?
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
The reason I think its the index is because if I:
1. Load a file in from XML import under /nodeA in workspace 1.
2. Clone nodeA to workspace2
2. Exit my application.
3. Delete nodeA from workspace 1 and 2
4. Reload a file in from XML import.
5. Do a XPATH query for a node in the imported data I get errors.
BUT if I:
1. Load a file in from XML import under /nodeA in workspace 1.
2. Clone nodeA to workspace2
2. Exit my application.
4. Delete the repository home directory manually
3. Delete nodeA from both workspace 1 and 2
4. Reload a file in from XML import.
5. Do a XPATH query for a node in the imported data I do NOTget errors.
Please advise as I my system is to go to production next week and its an
adminable consumer website for a company which expends a fair amount of
traffic on their site.
My code is below. Please let me know if anything looks weird. I have an
object per session that I lock whenever each of these sessions are modified.
The lock object is an instance variable on a singleton.
private void removeTopLevelNode(String name) {
Session prodSession =
JCRConnectionUtil.getInstance().getProductionSession();
Session previewSession =
JCRConnectionUtil.getInstance().getPreviewSession();
Boolean prodLockObject =
JCRConnectionUtil.getInstance().getProductionSessionLock();
Boolean previewLockObj =
JCRConnectionUtil.getInstance().getPreviewSessionLock();
try {
Node previewRoot = previewSession.getRootNode();
Node prodRoot = prodSession.getRootNode();
Node prodNode = null;
if (previewRoot.hasNode(name)) {
synchronized (previewLockObj) {
Node previewNode = previewRoot.getNode(name);
previewRoot.addMixin("mix:lockable");
JCRConnectionUtil.getInstance().savePreviewSession();
if (!previewRoot.isLocked()) {
previewRoot.lock(true, true);
}
previewNode.remove();
JCRConnectionUtil.getInstance().savePreviewSession();
previewRoot.unlock();
}
synchronized (previewLockObj) {
synchronized (prodLockObject) {
if (prodRoot.hasNode(name)) {
prodNode = prodRoot.getNode(name);
prodRoot.addMixin("mix:lockable");
JCRConnectionUtil.getInstance().saveProductionSession();
if (!prodRoot.isLocked()) {
prodRoot.lock(true, true);
}
if (prodRoot.hasNode(name)) {
if (prodRoot.hasNode(name)) {
logger.info("explicitly removing node");
prodNode.update(ConnectionManager.PREVIEW_WORKSPACE);
prodNode.remove();
JCRConnectionUtil.getInstance().saveProductionSession();
prodRoot.unlock();
JCRUtil.getInstance().listChildrenOfRoot(prodSession, "In PROD SESSION");
}
}
}
}
}
}
} catch (PathNotFoundException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:PathNotFoundException",
e);
} catch (VersionException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:VersionException", e);
} catch (LockException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:LockException", e);
} catch (ConstraintViolationException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:ConstraintViolationException",
e);
} catch (NoSuchWorkspaceException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:NoSuchWorkspaceException",
e);
} catch (AccessDeniedException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:AccessDeniedException",
e);
} catch (InvalidItemStateException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:InvalidItemStateException",
e);
} catch (RepositoryException e) {
logger.error("LegacyDataLoader:removeTopLevelNode:RepositoryException", e);
}
}
public static void importXMLFile(InputStream stream, String
topLevelNodeName) {
//removeNode(topLevelNodeName);
Session session = JCRUtil.getSession();
try {
if (session != null) {
if
(JCRConnectionUtil.getInstance().getCurrentSessionLock()!=null) {
Node root = session.getRootNode();
synchronized
(JCRConnectionUtil.getInstance().getCurrentSessionLock()) {
root.addMixin("mix:lockable");
JCRUtil.saveSession();
root.lock(true, true);
session.getWorkspace().importXML("/", stream,
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
session.save();
root.unlock();
}
}
}
} catch (PathNotFoundException e) {
logger.error("In ContentLoadUtil:importXMLFile,
PathNotFoundException: " + e);
} catch (ItemExistsException e) {
logger.error("In ContentLoadUtil:importXMLFile,
ItemExistsException: " + e);
} catch (ConstraintViolationException e) {
logger.error("In ContentLoadUtil:importXMLFile,
ConstraintViolationException: " + e);
} catch (VersionException e) {
logger.error("In ContentLoadUtil:importXMLFile,
VersionException: " + e);
} catch (InvalidSerializedDataException e) {
logger.error("In ContentLoadUtil:importXMLFile,
InvalidSerializedDataException: " + e);
} catch (LockException e) {
logger.error("In ContentLoadUtil:importXMLFile, LockException: "
+ e);
} catch (IOException e) {
logger.error("In ContentLoadUtil:importXMLFile, IOException: " +
e);
} catch (RepositoryException e) {
logger.error("In ContentLoadUtil:importXMLFile,
RepositoryException: " + e);
} finally {
try {
stream.close();
} catch (IOException e) {
logger.error("In ContentLoadUtil:importXMLFile, IOException:
" + e);
}
}
}
Regads
Alexander Klimetschek wrote:
>
> On Mon, May 4, 2009 at 11:57 PM, SalmasCM <sa...@criticalmass.com> wrote:
>> I've found that my latest problem is because when I delete a node from
>> the
>> preview workspace and its clone from the default workspace, these deletes
>> do
>> not trigger a lucene index refresh.
>> All works fine while the app is running, things are indexed fine, I can
>> drop
>> the nodes and reload as many times as I like but but if I stop my
>> application server and restart and then do the deletes then the indexres
>> are
>> out of wack. However, if I stop the server and manually delete the
>> indexes
>> then I do not get these errors.
>> Is there a way that I can programmatically make lucene reindex after the
>> deletes?
>
> The lucene index is automatically updated for all JCR operations,
> including node removal. What makes you think that the index is not
> updated? Please note that a node removal does not map to a simple file
> or directory delete in the lucene index, it's somewhat complex. The
> right way to test it is to run a search - after the delete, the node
> should no longer appear in the results.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23387753.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, May 4, 2009 at 11:57 PM, SalmasCM <sa...@criticalmass.com> wrote:
> I've found that my latest problem is because when I delete a node from the
> preview workspace and its clone from the default workspace, these deletes do
> not trigger a lucene index refresh.
> All works fine while the app is running, things are indexed fine, I can drop
> the nodes and reload as many times as I like but but if I stop my
> application server and restart and then do the deletes then the indexres are
> out of wack. However, if I stop the server and manually delete the indexes
> then I do not get these errors.
> Is there a way that I can programmatically make lucene reindex after the
> deletes?
The lucene index is automatically updated for all JCR operations,
including node removal. What makes you think that the index is not
updated? Please note that a node removal does not map to a simple file
or directory delete in the lucene index, it's somewhat complex. The
right way to test it is to run a search - after the delete, the node
should no longer appear in the results.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
I've found that my latest problem is because when I delete a node from the
preview workspace and its clone from the default workspace, these deletes do
not trigger a lucene index refresh.
All works fine while the app is running, things are indexed fine, I can drop
the nodes and reload as many times as I like but but if I stop my
application server and restart and then do the deletes then the indexres are
out of wack. However, if I stop the server and manually delete the indexes
then I do not get these errors.
Is there a way that I can programmatically make lucene reindex after the
deletes?
SalmasCM wrote:
>
> Hi:
>
> I got further but still some very frustrating errors. Now I both
> synchronize and lock for each session access. So I:
>
> 1. use the XML import to load a tree of data under a node which lives
> right under root.
> 2. I then modify this data by doing setProperty (locking and
> synchronizing)
> 3. I clone the data to the default workspace.
> 4. I exit my app.
> 5. I log in with a new session.
> 6. I delete the node from both preview and default workspaces.
> 7. reimport he data under the same name node
> 8. Atempt to invoke a Lucene query and get the following error
>
> failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
> cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
> dd740ff8-5108-40f2-9036-b6c769c86bd5
> javax.jcr.ItemNotFoundException: failed to build path of
> dd740ff8-5108-40f2-9036-b6c769c86bd5: cafebabe-cafe-babe-cafe-babecafebabe
> has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
> at
> org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
> at
> org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
> at org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
> at org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
> at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
> at com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
>
> However, when I do not do any modifications to the data then I do not get
> these errors.
>
>
> SalmasCM wrote:
>>
>> I am not convinced that this is a JackRabbit bug. It could well be but
>> it's more likely an issue in my application code. I believe it has to do
>> with concurrency and my using 2 sessions simultaneously. I believe that
>> something screws up with consurrency before I exit and then when I
>> restart my server everything is screwed up. I am going to try limiting
>> things to one thread per session by synchronizing on the same object
>> whenever I do something in preview and then having a second object that I
>> synchronize whenever I do something in the default workspace. I will let
>> you know if this solves things.
>> However, I do think that it would be nice to have documentation about
>> concurrency and how to do things in an application server environment.We
>> use BEA Weblogic which spawns a bunch of threads and so its probably more
>> challenging using Jackrabbit in this environment.
>>
>> Thanks so much for getting back to me. I have been struggling with this
>> and really need to get it working asap.
>>
>> Regards
>>
>>
>> Stefan Guggisberg wrote:
>>>
>>> On Sun, May 3, 2009 at 5:36 AM, SalmasCM <sa...@criticalmass.com>
>>> wrote:
>>>>
>>>> I have been trying for weeks to get things working in my application
>>>> and am
>>>> not making any progress.
>>>> I don't believe my use case is very unusual and I am hoping that you
>>>> will be
>>>> able to help me.
>>>>
>>>> 1. I have a lot of legacy data that I load in using the XML import
>>>> feature.
>>>> Each section is loaded under it's own top level node. The top level
>>>> nodes
>>>> live directly under root.
>>>> 2. I have 2 workspaces , preview and default. Changes and data loads
>>>> happen
>>>> in preview and are cloned/merged into default.
>>>>
>>>> Everything works if I bulk load the data with the XML import once but
>>>> falls
>>>> apart if I load a all the sections into preview and then clone to
>>>> default
>>>> and then later wish to reload a node with the XML import.
>>>>
>>>> I am unable to reload since it thinks it's a new node so if I reload
>>>> for
>>>> example employees then it creates employees[1] which is not what I
>>>> want.
>>>>
>>>> I have then 2 options.
>>>> 1. to force it to recognize the top node as the same node as previously
>>>> loaded, to do this I would have to indicate the UUID for the top node.
>>>> However, I have no idea how to make the UUID in the XML data file the
>>>> same
>>>> as it would create when reloading?
>>>> 2. So I tried to delete the node from both preview and default
>>>> workspaces
>>>> before loading. I ran into many issues and finally succeeded in
>>>> reloading
>>>> the data. However, I ran into issues when I modify any data in preview.
>>>>
>>>> I get
>>>>
>>>> Item cannot be saved because it has been modified externally: node /
>>>> javax.jcr.InvalidItemStateException: Item cannot be saved because it
>>>> has
>>>> been modified externally: node /
>>>>
>>>> This is the sequence of events.
>>>>
>>>> 1. load data using the XML loading under topNodeA in preview workspace
>>>> 2. I modify some of the data under topNodeA in preview workspace.
>>>> 3. I save the session etc.
>>>> 4. I clone the topNodeA and its subtree to the default space.
>>>> 4. I stop my application server and restart.
>>>> 5. I get a new session into the preview workspace
>>>> 6. I try to delete topNodeA in the preview workspace and then I get the
>>>> above error.
>>>
>>> without having seen your code i really can't tell but there might be a
>>> problem in your application logic. when you do restart and connect
>>> to the repository (assuming there isn't any other session interfering),
>>> i can't think of any way how this exception could be triggered.
>>>
>>> please provide a simple complete test case and your exact
>>> configuration/setup and i'll have a look what's going wrong.
>>>
>>> cheers
>>> stefan
>>>
>>>>
>>>> However, I do NOT receive this error when I do the following (do not
>>>> get out
>>>> of the existing session for that workspace and then subsequently get a
>>>> new
>>>> one but instead remain in the same session for the delete)
>>>>
>>>> 1. load data using the XML loading under topNodeA in preview workspace
>>>> 2. I modify some of the data under topNodeA in preview workspace.
>>>> 3. I save the session etc.
>>>> 4. I clone the topNodeA and its subtree to the default space.
>>>> 5. I try to delete topNodeA in the preview workspace and then I DO NOT
>>>> get
>>>> the above error.
>>>>
>>>> I lock the node while making changes like so:
>>>>
>>>> /**
>>>> *
>>>> * @param nodeToSet
>>>> * The node in which to set the property.
>>>> * @param attribute
>>>> * @param value
>>>> */
>>>> public static boolean saveAttribute(Node nodeToSet, String
>>>> attribute,
>>>> Object value) {
>>>> boolean success = false;
>>>> if ((nodeToSet != null) && (attribute != null) && (value !=
>>>> null)) {
>>>> try {
>>>> synchronized (nodeToSet) {
>>>> boolean iLockedThis=false;
>>>> if (!nodeToSet.isLocked()) {
>>>> nodeToSet.addMixin("mix:lockable");
>>>> session.save();
>>>> nodeToSet.lock(true, true);
>>>> iLockedThis=true;
>>>> }
>>>> if (value instanceof InputStream) {
>>>> nodeToSet.setProperty(attribute, (InputStream)
>>>> value);
>>>> try {
>>>> ((InputStream) value).close();
>>>> } catch (IOException e) {
>>>> getInstance().logger.error("IOException
>>>> in:saveAttribute " + e);
>>>> }
>>>> success = true;
>>>> } else if (value instanceof Calendar) {
>>>> nodeToSet.setProperty(attribute, (Calendar)
>>>> value);
>>>> success = true;
>>>> } else if (value instanceof String) {
>>>> String stringToSet = (String) value;
>>>> nodeToSet.setProperty(attribute, stringToSet);
>>>> success = true;
>>>> } else if (value instanceof Long) {
>>>> nodeToSet.setProperty(attribute, ((Long)
>>>> value).longValue());
>>>> success = true;
>>>> } else if (value instanceof Integer) {
>>>> nodeToSet.setProperty(attribute, ((Integer)
>>>> value).longValue());
>>>> success = true;
>>>> } else if (value instanceof Double) {
>>>> nodeToSet.setProperty(attribute, ((Double)
>>>> value).doubleValue());
>>>> success = true;
>>>> } else if (value instanceof Boolean) {
>>>> nodeToSet.setProperty(attribute, ((Boolean)
>>>> value).booleanValue());
>>>> success = true;
>>>> }
>>>> if (iLockedThis) {
>>>> session.save();
>>>> nodeToSet.unlock();
>>>> }
>>>> }
>>>> } catch (final javax.jcr.ValueFormatException e) {
>>>> getInstance().logger.error("ValueFormatException
>>>> in:saveAttribute " + e);
>>>> } catch (final javax.jcr.version.VersionException e) {
>>>> getInstance().logger.error("VersionException
>>>> in:saveAttribute " + e);
>>>> } catch (final javax.jcr.lock.LockException e) {
>>>> getInstance().logger.error("LockException
>>>> in:saveAttribute "
>>>> + e);
>>>> } catch (final
>>>> javax.jcr.nodetype.ConstraintViolationException
>>>> e) {
>>>>
>>>> getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
>>>> in:saveAttribute " + e);
>>>> } catch (final javax.jcr.RepositoryException e) {
>>>> getInstance().logger.error("RepositoryException
>>>> in:saveAttribute " + e);
>>>> }
>>>> }
>>>> return success;
>>>> }
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23377399.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
Hi:
I got further but still some very frustrating errors. Now I both synchronize
and lock for each session access. So I:
1. use the XML import to load a tree of data under a node which lives right
under root.
2. I then modify this data by doing setProperty (locking and synchronizing)
3. I clone the data to the default workspace.
4. I exit my app.
5. I log in with a new session.
6. I delete the node from both preview and default workspaces.
7. reimport he data under the same name node
8. Atempt to invoke a Lucene query and get the following error
failed to build path of dd740ff8-5108-40f2-9036-b6c769c86bd5:
cafebabe-cafe-babe-cafe-babecafebabe has no child entry for
dd740ff8-5108-40f2-9036-b6c769c86bd5
javax.jcr.ItemNotFoundException: failed to build path of
dd740ff8-5108-40f2-9036-b6c769c86bd5: cafebabe-cafe-babe-cafe-babecafebabe
has no child entry for dd740ff8-5108-40f2-9036-b6c769c86bd5
at
org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:289)
at
org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
at
org.apache.jackrabbit.core.HierarchyManagerImpl.buildPath(HierarchyManagerImpl.java:278)
at
org.apache.jackrabbit.core.CachingHierarchyManager.buildPath(CachingHierarchyManager.java:195)
at
org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(HierarchyManagerImpl.java:393)
at
org.apache.jackrabbit.core.CachingHierarchyManager.getPath(CachingHierarchyManager.java:229)
at org.apache.jackrabbit.core.ItemImpl.getPrimaryPath(ItemImpl.java:213)
at org.apache.jackrabbit.core.NodeImpl.getPrimaryPath(NodeImpl.java:3240)
at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:1273)
at com.ashland.valvoline.ui.util.JCRUtil.getNodePath(JCRUtil.java:2353)
However, when I do not do any modifications to the data then I do not get
these errors.
SalmasCM wrote:
>
> I am not convinced that this is a JackRabbit bug. It could well be but
> it's more likely an issue in my application code. I believe it has to do
> with concurrency and my using 2 sessions simultaneously. I believe that
> something screws up with consurrency before I exit and then when I restart
> my server everything is screwed up. I am going to try limiting things to
> one thread per session by synchronizing on the same object whenever I do
> something in preview and then having a second object that I synchronize
> whenever I do something in the default workspace. I will let you know if
> this solves things.
> However, I do think that it would be nice to have documentation about
> concurrency and how to do things in an application server environment.We
> use BEA Weblogic which spawns a bunch of threads and so its probably more
> challenging using Jackrabbit in this environment.
>
> Thanks so much for getting back to me. I have been struggling with this
> and really need to get it working asap.
>
> Regards
>
>
> Stefan Guggisberg wrote:
>>
>> On Sun, May 3, 2009 at 5:36 AM, SalmasCM <sa...@criticalmass.com> wrote:
>>>
>>> I have been trying for weeks to get things working in my application and
>>> am
>>> not making any progress.
>>> I don't believe my use case is very unusual and I am hoping that you
>>> will be
>>> able to help me.
>>>
>>> 1. I have a lot of legacy data that I load in using the XML import
>>> feature.
>>> Each section is loaded under it's own top level node. The top level
>>> nodes
>>> live directly under root.
>>> 2. I have 2 workspaces , preview and default. Changes and data loads
>>> happen
>>> in preview and are cloned/merged into default.
>>>
>>> Everything works if I bulk load the data with the XML import once but
>>> falls
>>> apart if I load a all the sections into preview and then clone to
>>> default
>>> and then later wish to reload a node with the XML import.
>>>
>>> I am unable to reload since it thinks it's a new node so if I reload for
>>> example employees then it creates employees[1] which is not what I want.
>>>
>>> I have then 2 options.
>>> 1. to force it to recognize the top node as the same node as previously
>>> loaded, to do this I would have to indicate the UUID for the top node.
>>> However, I have no idea how to make the UUID in the XML data file the
>>> same
>>> as it would create when reloading?
>>> 2. So I tried to delete the node from both preview and default
>>> workspaces
>>> before loading. I ran into many issues and finally succeeded in
>>> reloading
>>> the data. However, I ran into issues when I modify any data in preview.
>>>
>>> I get
>>>
>>> Item cannot be saved because it has been modified externally: node /
>>> javax.jcr.InvalidItemStateException: Item cannot be saved because it has
>>> been modified externally: node /
>>>
>>> This is the sequence of events.
>>>
>>> 1. load data using the XML loading under topNodeA in preview workspace
>>> 2. I modify some of the data under topNodeA in preview workspace.
>>> 3. I save the session etc.
>>> 4. I clone the topNodeA and its subtree to the default space.
>>> 4. I stop my application server and restart.
>>> 5. I get a new session into the preview workspace
>>> 6. I try to delete topNodeA in the preview workspace and then I get the
>>> above error.
>>
>> without having seen your code i really can't tell but there might be a
>> problem in your application logic. when you do restart and connect
>> to the repository (assuming there isn't any other session interfering),
>> i can't think of any way how this exception could be triggered.
>>
>> please provide a simple complete test case and your exact
>> configuration/setup and i'll have a look what's going wrong.
>>
>> cheers
>> stefan
>>
>>>
>>> However, I do NOT receive this error when I do the following (do not get
>>> out
>>> of the existing session for that workspace and then subsequently get a
>>> new
>>> one but instead remain in the same session for the delete)
>>>
>>> 1. load data using the XML loading under topNodeA in preview workspace
>>> 2. I modify some of the data under topNodeA in preview workspace.
>>> 3. I save the session etc.
>>> 4. I clone the topNodeA and its subtree to the default space.
>>> 5. I try to delete topNodeA in the preview workspace and then I DO NOT
>>> get
>>> the above error.
>>>
>>> I lock the node while making changes like so:
>>>
>>> /**
>>> *
>>> * @param nodeToSet
>>> * The node in which to set the property.
>>> * @param attribute
>>> * @param value
>>> */
>>> public static boolean saveAttribute(Node nodeToSet, String attribute,
>>> Object value) {
>>> boolean success = false;
>>> if ((nodeToSet != null) && (attribute != null) && (value !=
>>> null)) {
>>> try {
>>> synchronized (nodeToSet) {
>>> boolean iLockedThis=false;
>>> if (!nodeToSet.isLocked()) {
>>> nodeToSet.addMixin("mix:lockable");
>>> session.save();
>>> nodeToSet.lock(true, true);
>>> iLockedThis=true;
>>> }
>>> if (value instanceof InputStream) {
>>> nodeToSet.setProperty(attribute, (InputStream)
>>> value);
>>> try {
>>> ((InputStream) value).close();
>>> } catch (IOException e) {
>>> getInstance().logger.error("IOException
>>> in:saveAttribute " + e);
>>> }
>>> success = true;
>>> } else if (value instanceof Calendar) {
>>> nodeToSet.setProperty(attribute, (Calendar)
>>> value);
>>> success = true;
>>> } else if (value instanceof String) {
>>> String stringToSet = (String) value;
>>> nodeToSet.setProperty(attribute, stringToSet);
>>> success = true;
>>> } else if (value instanceof Long) {
>>> nodeToSet.setProperty(attribute, ((Long)
>>> value).longValue());
>>> success = true;
>>> } else if (value instanceof Integer) {
>>> nodeToSet.setProperty(attribute, ((Integer)
>>> value).longValue());
>>> success = true;
>>> } else if (value instanceof Double) {
>>> nodeToSet.setProperty(attribute, ((Double)
>>> value).doubleValue());
>>> success = true;
>>> } else if (value instanceof Boolean) {
>>> nodeToSet.setProperty(attribute, ((Boolean)
>>> value).booleanValue());
>>> success = true;
>>> }
>>> if (iLockedThis) {
>>> session.save();
>>> nodeToSet.unlock();
>>> }
>>> }
>>> } catch (final javax.jcr.ValueFormatException e) {
>>> getInstance().logger.error("ValueFormatException
>>> in:saveAttribute " + e);
>>> } catch (final javax.jcr.version.VersionException e) {
>>> getInstance().logger.error("VersionException
>>> in:saveAttribute " + e);
>>> } catch (final javax.jcr.lock.LockException e) {
>>> getInstance().logger.error("LockException
>>> in:saveAttribute "
>>> + e);
>>> } catch (final
>>> javax.jcr.nodetype.ConstraintViolationException
>>> e) {
>>>
>>> getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
>>> in:saveAttribute " + e);
>>> } catch (final javax.jcr.RepositoryException e) {
>>> getInstance().logger.error("RepositoryException
>>> in:saveAttribute " + e);
>>> }
>>> }
>>> return success;
>>> }
>>> --
>>> View this message in context:
>>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23376919.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by SalmasCM <sa...@criticalmass.com>.
I am not convinced that this is a JackRabbit bug. It could well be but it's
more likely an issue in my application code. I believe it has to do with
concurrency and my using 2 sessions simultaneously. I believe that something
screws up with consurrency before I exit and then when I restart my server
everything is screwed up. I am going to try limiting things to one thread
per session by synchronizing on the same object whenever I do something in
preview and then having a second object that I synchronize whenever I do
something in the default workspace. I will let you know if this solves
things.
However, I do think that it would be nice to have documentation about
concurrency and how to do things in an application server environment.We use
BEA Weblogic which spawns a bunch of threads and so its probably more
challenging using Jackrabbit in this environment.
Thanks so much for getting back to me. I have been struggling with this and
really need to get it working asap.
Regards
Stefan Guggisberg wrote:
>
> On Sun, May 3, 2009 at 5:36 AM, SalmasCM <sa...@criticalmass.com> wrote:
>>
>> I have been trying for weeks to get things working in my application and
>> am
>> not making any progress.
>> I don't believe my use case is very unusual and I am hoping that you will
>> be
>> able to help me.
>>
>> 1. I have a lot of legacy data that I load in using the XML import
>> feature.
>> Each section is loaded under it's own top level node. The top level nodes
>> live directly under root.
>> 2. I have 2 workspaces , preview and default. Changes and data loads
>> happen
>> in preview and are cloned/merged into default.
>>
>> Everything works if I bulk load the data with the XML import once but
>> falls
>> apart if I load a all the sections into preview and then clone to default
>> and then later wish to reload a node with the XML import.
>>
>> I am unable to reload since it thinks it's a new node so if I reload for
>> example employees then it creates employees[1] which is not what I want.
>>
>> I have then 2 options.
>> 1. to force it to recognize the top node as the same node as previously
>> loaded, to do this I would have to indicate the UUID for the top node.
>> However, I have no idea how to make the UUID in the XML data file the
>> same
>> as it would create when reloading?
>> 2. So I tried to delete the node from both preview and default workspaces
>> before loading. I ran into many issues and finally succeeded in reloading
>> the data. However, I ran into issues when I modify any data in preview.
>>
>> I get
>>
>> Item cannot be saved because it has been modified externally: node /
>> javax.jcr.InvalidItemStateException: Item cannot be saved because it has
>> been modified externally: node /
>>
>> This is the sequence of events.
>>
>> 1. load data using the XML loading under topNodeA in preview workspace
>> 2. I modify some of the data under topNodeA in preview workspace.
>> 3. I save the session etc.
>> 4. I clone the topNodeA and its subtree to the default space.
>> 4. I stop my application server and restart.
>> 5. I get a new session into the preview workspace
>> 6. I try to delete topNodeA in the preview workspace and then I get the
>> above error.
>
> without having seen your code i really can't tell but there might be a
> problem in your application logic. when you do restart and connect
> to the repository (assuming there isn't any other session interfering),
> i can't think of any way how this exception could be triggered.
>
> please provide a simple complete test case and your exact
> configuration/setup and i'll have a look what's going wrong.
>
> cheers
> stefan
>
>>
>> However, I do NOT receive this error when I do the following (do not get
>> out
>> of the existing session for that workspace and then subsequently get a
>> new
>> one but instead remain in the same session for the delete)
>>
>> 1. load data using the XML loading under topNodeA in preview workspace
>> 2. I modify some of the data under topNodeA in preview workspace.
>> 3. I save the session etc.
>> 4. I clone the topNodeA and its subtree to the default space.
>> 5. I try to delete topNodeA in the preview workspace and then I DO NOT
>> get
>> the above error.
>>
>> I lock the node while making changes like so:
>>
>> /**
>> *
>> * @param nodeToSet
>> * The node in which to set the property.
>> * @param attribute
>> * @param value
>> */
>> public static boolean saveAttribute(Node nodeToSet, String attribute,
>> Object value) {
>> boolean success = false;
>> if ((nodeToSet != null) && (attribute != null) && (value != null))
>> {
>> try {
>> synchronized (nodeToSet) {
>> boolean iLockedThis=false;
>> if (!nodeToSet.isLocked()) {
>> nodeToSet.addMixin("mix:lockable");
>> session.save();
>> nodeToSet.lock(true, true);
>> iLockedThis=true;
>> }
>> if (value instanceof InputStream) {
>> nodeToSet.setProperty(attribute, (InputStream)
>> value);
>> try {
>> ((InputStream) value).close();
>> } catch (IOException e) {
>> getInstance().logger.error("IOException
>> in:saveAttribute " + e);
>> }
>> success = true;
>> } else if (value instanceof Calendar) {
>> nodeToSet.setProperty(attribute, (Calendar)
>> value);
>> success = true;
>> } else if (value instanceof String) {
>> String stringToSet = (String) value;
>> nodeToSet.setProperty(attribute, stringToSet);
>> success = true;
>> } else if (value instanceof Long) {
>> nodeToSet.setProperty(attribute, ((Long)
>> value).longValue());
>> success = true;
>> } else if (value instanceof Integer) {
>> nodeToSet.setProperty(attribute, ((Integer)
>> value).longValue());
>> success = true;
>> } else if (value instanceof Double) {
>> nodeToSet.setProperty(attribute, ((Double)
>> value).doubleValue());
>> success = true;
>> } else if (value instanceof Boolean) {
>> nodeToSet.setProperty(attribute, ((Boolean)
>> value).booleanValue());
>> success = true;
>> }
>> if (iLockedThis) {
>> session.save();
>> nodeToSet.unlock();
>> }
>> }
>> } catch (final javax.jcr.ValueFormatException e) {
>> getInstance().logger.error("ValueFormatException
>> in:saveAttribute " + e);
>> } catch (final javax.jcr.version.VersionException e) {
>> getInstance().logger.error("VersionException
>> in:saveAttribute " + e);
>> } catch (final javax.jcr.lock.LockException e) {
>> getInstance().logger.error("LockException in:saveAttribute
>> "
>> + e);
>> } catch (final javax.jcr.nodetype.ConstraintViolationException
>> e) {
>>
>> getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
>> in:saveAttribute " + e);
>> } catch (final javax.jcr.RepositoryException e) {
>> getInstance().logger.error("RepositoryException
>> in:saveAttribute " + e);
>> }
>> }
>> return success;
>> }
>> --
>> View this message in context:
>> http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23370294.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: modified externally: node / when deleting node
Posted by Stefan Guggisberg <st...@gmail.com>.
On Sun, May 3, 2009 at 5:36 AM, SalmasCM <sa...@criticalmass.com> wrote:
>
> I have been trying for weeks to get things working in my application and am
> not making any progress.
> I don't believe my use case is very unusual and I am hoping that you will be
> able to help me.
>
> 1. I have a lot of legacy data that I load in using the XML import feature.
> Each section is loaded under it's own top level node. The top level nodes
> live directly under root.
> 2. I have 2 workspaces , preview and default. Changes and data loads happen
> in preview and are cloned/merged into default.
>
> Everything works if I bulk load the data with the XML import once but falls
> apart if I load a all the sections into preview and then clone to default
> and then later wish to reload a node with the XML import.
>
> I am unable to reload since it thinks it's a new node so if I reload for
> example employees then it creates employees[1] which is not what I want.
>
> I have then 2 options.
> 1. to force it to recognize the top node as the same node as previously
> loaded, to do this I would have to indicate the UUID for the top node.
> However, I have no idea how to make the UUID in the XML data file the same
> as it would create when reloading?
> 2. So I tried to delete the node from both preview and default workspaces
> before loading. I ran into many issues and finally succeeded in reloading
> the data. However, I ran into issues when I modify any data in preview.
>
> I get
>
> Item cannot be saved because it has been modified externally: node /
> javax.jcr.InvalidItemStateException: Item cannot be saved because it has
> been modified externally: node /
>
> This is the sequence of events.
>
> 1. load data using the XML loading under topNodeA in preview workspace
> 2. I modify some of the data under topNodeA in preview workspace.
> 3. I save the session etc.
> 4. I clone the topNodeA and its subtree to the default space.
> 4. I stop my application server and restart.
> 5. I get a new session into the preview workspace
> 6. I try to delete topNodeA in the preview workspace and then I get the
> above error.
without having seen your code i really can't tell but there might be a
problem in your application logic. when you do restart and connect
to the repository (assuming there isn't any other session interfering),
i can't think of any way how this exception could be triggered.
please provide a simple complete test case and your exact
configuration/setup and i'll have a look what's going wrong.
cheers
stefan
>
> However, I do NOT receive this error when I do the following (do not get out
> of the existing session for that workspace and then subsequently get a new
> one but instead remain in the same session for the delete)
>
> 1. load data using the XML loading under topNodeA in preview workspace
> 2. I modify some of the data under topNodeA in preview workspace.
> 3. I save the session etc.
> 4. I clone the topNodeA and its subtree to the default space.
> 5. I try to delete topNodeA in the preview workspace and then I DO NOT get
> the above error.
>
> I lock the node while making changes like so:
>
> /**
> *
> * @param nodeToSet
> * The node in which to set the property.
> * @param attribute
> * @param value
> */
> public static boolean saveAttribute(Node nodeToSet, String attribute,
> Object value) {
> boolean success = false;
> if ((nodeToSet != null) && (attribute != null) && (value != null)) {
> try {
> synchronized (nodeToSet) {
> boolean iLockedThis=false;
> if (!nodeToSet.isLocked()) {
> nodeToSet.addMixin("mix:lockable");
> session.save();
> nodeToSet.lock(true, true);
> iLockedThis=true;
> }
> if (value instanceof InputStream) {
> nodeToSet.setProperty(attribute, (InputStream)
> value);
> try {
> ((InputStream) value).close();
> } catch (IOException e) {
> getInstance().logger.error("IOException
> in:saveAttribute " + e);
> }
> success = true;
> } else if (value instanceof Calendar) {
> nodeToSet.setProperty(attribute, (Calendar) value);
> success = true;
> } else if (value instanceof String) {
> String stringToSet = (String) value;
> nodeToSet.setProperty(attribute, stringToSet);
> success = true;
> } else if (value instanceof Long) {
> nodeToSet.setProperty(attribute, ((Long)
> value).longValue());
> success = true;
> } else if (value instanceof Integer) {
> nodeToSet.setProperty(attribute, ((Integer)
> value).longValue());
> success = true;
> } else if (value instanceof Double) {
> nodeToSet.setProperty(attribute, ((Double)
> value).doubleValue());
> success = true;
> } else if (value instanceof Boolean) {
> nodeToSet.setProperty(attribute, ((Boolean)
> value).booleanValue());
> success = true;
> }
> if (iLockedThis) {
> session.save();
> nodeToSet.unlock();
> }
> }
> } catch (final javax.jcr.ValueFormatException e) {
> getInstance().logger.error("ValueFormatException
> in:saveAttribute " + e);
> } catch (final javax.jcr.version.VersionException e) {
> getInstance().logger.error("VersionException
> in:saveAttribute " + e);
> } catch (final javax.jcr.lock.LockException e) {
> getInstance().logger.error("LockException in:saveAttribute "
> + e);
> } catch (final javax.jcr.nodetype.ConstraintViolationException
> e) {
>
> getInstance().logger.error("javax.jcr.nodetype.ConstraintViolationException
> in:saveAttribute " + e);
> } catch (final javax.jcr.RepositoryException e) {
> getInstance().logger.error("RepositoryException
> in:saveAttribute " + e);
> }
> }
> return success;
> }
> --
> View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23352361.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>