AnsweredAssumed Answered

Transaction rolled back

Question asked by hbf on Jan 10, 2008
Latest reply on Oct 9, 2008 by derek
Hi,

I need some advice from a Spring transaction guru, it seems: I don't get the following to work


    try {
      UserTransaction transaction = transactionService.getNonPropagatingUserTransaction();
      transaction.begin();
      authenticationService.authenticate(LOGIN, PASSWORD.toCharArray());
      NodeRef nodeRef = new NodeRef("workspace://SpacesStore/rubbish"); // invalid input
      int status = alfrescoContext.getTransaction().getStatus(); // 0
      nodeService.getProperty(nodeRef, ContentModel.PROP_CATEGORIES);
    }
    catch (Exception e)
    {
      int status = alfrescoContext.getTransaction().getStatus(); // (*)
    }
    transaction.commit();

This code is executed in a seperate Tomcat webapp running alongside the Alfresco Web Client webapp.

With a valid node-ref, the code works perfectly. With the invalid node-ref (as above), getProperty() throws an InvalidNodeRefException exception and already at (*), the transaction's status is 1= STATUS_MARKED_ROLLBACK. Spring is probably intercepting, right?

My question: Why does this mark the transaction for rollback? Is it my duty to make sure the node-ref is correct? I would have thought that if I caught the exception, I can fix the problem and try again (for which, of course, I need a transaction that is not yet marked for rollback)?

Regards,
Kaspar

Outcomes