cancel
Showing results for 
Search instead for 
Did you mean: 

Detected stale node entry exception

spilby
Confirmed Champ
Confirmed Champ
I found an error on my application when I try to create multiple nodes on Alfresco. I use Java Custom Webscripts. I want to create 20.000 new nodes with documents on a while bucle. I throw this code multiple times and all works ok. I have created 100.000 nodes. But when I thrown another time the code, an error broke my execution. I found in a log this:

EXCEPTION: org.springframework.dao.DataIntegrityViolationException: Detected stale node entry: NodeVersionKey [nodeId=373526, version=8] (now [NodeVersionKey [nodeId=373526, version=11]]

The code try to create this node multiple times, but the exception occurs again and again.

When occurs this exceptions? What's may be the cause that changes the version from 8 to 11?


I add my code for more information about the problem…

This is my code, when I create a node:



NodeRef nodeRef = null;
       
try {
       
    properties.put(ContentModel.PROP_NAME, name); 
   
    nodeRef = getNodeService().createNode(
                           parent,
                           ContentModel.ASSOC_CONTAINS,
                           QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
                           type,
                           properties).getChildRef();
                    
          
    if (nodeRef!=null) {
          
        QName CUSTOM_ASPECT_QNAME = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, Constants.aspectTitled);
        Map<QName,Serializable> aspectValues = new HashMap<QName,Serializable>();
        aspectValues.put(QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, Constants.titleProperty), title);
        aspectValues.put(QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, Constants.descriptionProperty), description);
        getNodeService().addAspect(nodeRef, CUSTOM_ASPECT_QNAME, aspectValues);
          
    }



And inside the while, I do a RetryingTransactionCallback to create each node each time.


boolean readonly = false;
boolean requiresNew = true

RetryingTransactionCallback<Object> txnWork = new RetryingTransactionCallback<Object>() {
   public Object execute() throws Throwable {
               Create the node…
             }
};
     
TransactionService transactionService = serviceRegistry.getTransactionService();
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, readonly, requiresNew);



Thanks a lot!
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Can't see anything wrong with the code you have posted.

However your description of your issue(s) is/are unclear/ and you don't even specify basic details like version of alfresco used.

The stale node exception is associated with versioning but your code snippets above do not mention versioning.

spilby
Confirmed Champ
Confirmed Champ
Thanks, mrogers. My alfresco jars are 4.1.6 version.

No, I don't use versioning on my alfresco parameters with the calls. In fact, I don't know what is versioning on a node creation.

Which information can I give you for better clarification of the problem?

Thanks again

Best regards

spilby
Confirmed Champ
Confirmed Champ
Goog morning,

any suggestions? No one meets with this exception? A few information may be useful for me.

Thanks.

Best regards!

jack0077
Champ in-the-making
Champ in-the-making
Did you find solution of your problem? Any answers why this exception occurs?