cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Explorer blocks properties when I change it?

spilby
Confirmed Champ
Confirmed Champ
I have a problem after using the Alfresco Explorer.

I have created a java webscript to create nodes and modify properties, into a transaction, oks? All works fine when I use the webscript. I create folders, subfolders, modify the properties, all ok.

But then, I do the following… I go to the Alfresco Explorer. Find one of the folders and edit the properties, modify something and save.

After I do this, when I use my webscript and try to change a property of one of the nodes that I changed before with the Alfresco Explorer, a exception is thrown: "ConcurrencyFailureException: Failed to update node". And I can't change or add properties on this node. Only if I restart the server I can update with my webscript the node again and all works fine another time.

First I thank that was a problem in my code, but if so, it would never works. Or it doesn't works after the restart. But no, the code works always if I don't use the Alfresco Explorer, and works again if I restart the tomcat server where alfresco runs.

Are there a problem with the Alfresco Explorer that blocks the properties of the nodes when someone change it? What might be the problem? I'm using Alfresco Enterprise v4.1.6.

Thanks!
23 REPLIES 23

sanket
Champ on-the-rise
Champ on-the-rise
Any specific reason of using

UserTransaction trx = serviceRegistry.getTransactionService().getNonPropagatingUserTransaction();

instead of
 
UserTransaction tx=serviceRegistry.getTransactionService().getUserTransaction();

spilby
Confirmed Champ
Confirmed Champ
No, simply he recommends me the nonpropagating method, to use a new transaction. Is better option the other? Other users specify the transactionality with the XML.

Anyway, the problem appears using each of this two methods. I don't know what causes the exceptions. Seems that Alfresco Explorer blocks the node and I can't update the properties, until I restart the server. But how can I resolve this?

sanket
Champ on-the-rise
Champ on-the-rise
Can you try embedding your entire webscript code within a single UserTransaction block

UserTransaction tx=serviceRegistry.getTransactionService().getUserTransaction();
try {
      trx.begin();
            // all your code
           trx.commit();
} catch(WebScriptException e) {
      trx.rollback();
      logger.error("ERROR: " + e);
      throw new WebScriptException(Status.STATUS_PROPERTIES_ERROR, e.getMessage());
   }

spilby
Confirmed Champ
Confirmed Champ
No works, doing it I have another time the exception. I think that use the transaction on each node operation forces the commit and the block that appears when use the Alfresco Explorer dissapears. But I'm not sure if it's the real reason.

mrogers
Star Contributor
Star Contributor
One reason to use Alfresco's RetryingTransactionHelper is that it will not leak transactions.     And will retry. 

The following code is incorrect and dangerous
try {

      trx.begin();

            // all your code

           trx.commit();

} catch(WebScriptException e) {

The above transaction handling is incorrect and dangerous,  what happens if there's something other than a WebScriptException thrown?

spilby
Confirmed Champ
Confirmed Champ
Sorry, my mistake when write the code here. The real catch in my code is Throwable, not WebScriptException.

But how can I use the RetryingTransactionHelper in my code? Is a better option than the begin and commit transaction? I don't use the RetryingTransactionHelper  because although I read about this, I don't understand how use it in my code.

Anyway, I understand that the RetryingTransactionHelper can help me if my code blocks a node. But if I don't use the Alfresco Explorer all go without problems. Seems that is the modification with the explorer that blocks the node. But is someone could tell me how I can use the RetryingTransactionHelper in my code, I would be very grateful to test it and comment the results. I don't understand how can I use it, sorry.



spilby
Confirmed Champ
Confirmed Champ
Any help with the RetryingTransactionHelper? Someone who use it? I don't know if it resolves the problem, but I must test it. I try to put in my code but don't works, I think I don't put it ok.

spilby
Confirmed Champ
Confirmed Champ
Yes, this is the post that I had read, but I don't understand how can I adapt it to my code.

For example… I have this simple method:


public NodeRef transactionCreateNode(NodeRef parent, Map<QName, Serializable> properties, String name) throws Exception {
       NodeRef nodeRef = null;
       UserTransaction trx = serviceRegistry.getTransactionService().getNonPropagatingUserTransaction();
      
       try {
         trx.begin();
         nodeRef = this.createNode(parent, properties, name);
         trx.commit();
      } catch(Throwable e) {
         trx.rollback();
         logger.error("transactionCreateNode- ERROR: " + e);
         throw new Exception(e);
      }   
      
       return nodeRef;
    }

Who call the method that creates a node, into a transaction. But if I try to integrate the RetryingTransactionHelper, I suppose that I must do something like this:


public NodeRef transactionCreateNode(NodeRef parent, Map<QName, Serializable> properties, String name) throws Exception {
Boolean result = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>(){
    public Boolean execute() throws Throwable {

      boolean success= this.createNode(parent, properties, name);
      if (!success)
         throw new IllegalStateException("Error creating node");

      return true;
    }  

}, false, true);
}


But the Eclipse give me compilation errors because don't know the createNode method, and parent, properties, name vars. What's incorrect? 

sanket
Champ on-the-rise
Champ on-the-rise
Use this :


RetryingTransactionCallback<Object> txnWork = new RetryingTransactionCallback<Object>()
                {
                    public Object execute() throws Exception
                    {
                        // Your code goes here
                        return result; //return null atleast if you have nothing to return to prevent compilation errors.
                    }
                };
                TransactionService transactionService = serviceRegistry.getTransactionService();
                Object result = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, true);

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.