cancel
Showing results for 
Search instead for 
Did you mean: 

Adding aspects and lockiing nodes in one transaction

akomisarek
Champ in-the-making
Champ in-the-making
Hello,

I am having issues with following scenario which is performed in Dialog (I looked into BaseDialogBean code it seems my all action are wrapped into transaction which is something I would expect and shouldn't be worrying about that):

1. If acted node is not multilingual made node multilingual.
2. Create node in different languages input by user from the dialog (making them multilingual -> adding ml Aspect)
3. Add aspect with my data if it doesn't exists. If it exists it is modified.
4. Lock nodes created in step 2.

If i debug locking is successful no problems at all.. The issues arise from alfresco after executing of my bean, node is locked obviously because I did it, and it seems during commit is onAddAspect fired:

09:04:56,390 User:admin ERROR [ui.common.Utils] A system error happened during the operation: 10300003 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnAddAspectPolicy.onAddAspect(org.alfresco.service.cmr.repository.NodeRef,org.alfresco.service.namespace.QName) in transaction 14e8bc88-b9ad-4550-bf25-20f390c691e3
org.alfresco.error.AlfrescoRuntimeException: 10300003 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnAddAspectPolicy.onAddAspect(org.alfresco.service.cmr.repository.NodeRef,org.alfresco.service.namespace.QName) in transaction 14e8bc88-b9ad-4550-bf25-20f390c691e3
    at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:201)
    at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(TransactionBehaviourQueue.java:133)
    at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:739)
    at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:719)
    at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:679)
    at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:48)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:835)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:645)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
    at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:467)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:340)
    at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:130)
    at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:534)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
    at javax.faces.component.UICommand.broadcast(UICommand.java:109)
    at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
    at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
    at sun.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy189.doFilter(Unknown Source)
    at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
    at sun.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy189.doFilter(Unknown Source)
    at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
Caused by: org.alfresco.service.cmr.lock.NodeLockedException: 10300002 Can not perform operation since the node (id:ffec06ee-7b9a-439c-9484-19339426b6b1) is locked.
    at org.alfresco.repo.lock.LockServiceImpl.checkForLock(LockServiceImpl.java:502)
    at org.alfresco.repo.lock.LockServiceImpl.beforeCreateVersion(LockServiceImpl.java:584)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.invoke(JavaBehaviour.java:179)
    at $Proxy29.beforeCreateVersion(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor600.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.policy.PolicyFactory$MultiHandler.invoke(PolicyFactory.java:306)
    at org.alfresco.repo.policy.$Proxy204.beforeCreateVersion(Unknown Source)
    at org.alfresco.repo.version.common.AbstractVersionServiceImpl.invokeBeforeCreateVersion(AbstractVersionServiceImpl.java:132)
    at org.alfresco.repo.version.Version2ServiceImpl.createVersion(Version2ServiceImpl.java:205)
    at org.alfresco.repo.version.Version2ServiceImpl.createVersion(Version2ServiceImpl.java:129)
    at org.alfresco.repo.version.VersionableAspect.onAddAspect(VersionableAspect.java:260)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.invoke(JavaBehaviour.java:179)
    at $Proxy12.onAddAspect(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor467.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:189)
    … 60 more

What should I do? Is there any workaround? Should I create different transaction for making my nodes multilingual? It seems a bit unnatural though..

Thanks,
Adam
3 REPLIES 3

akomisarek
Champ in-the-making
Champ in-the-making
Hmm I am trying to fix it somehow but it seems I can't run anything in other transaction:

when I create RetryingTransactionHelper object in my bean expression helper.doInTransaction(callback, false, true); raises exception. txnService field in helper object is null and I get null pointer exception in alfresco's code:

                if (requiresNew)
                {
                    txn = txnService.getNonPropagatingUserTransaction(readOnly);
                }

I work on 3.2r version (built from 16803 revision).

Edit: added version and code. Changed sentence

Thanks in advance.

akomisarek
Champ in-the-making
Champ in-the-making
Ignore my second post I found I should get transaction helper from repository rather than creating my own Smiley Happy.

Last update from my side:

If I do my whole content in new transaction alfresco doesn't see my changes Smiley Sad. So my documents aren't Multilingual / haven't aspects added / aren't locked. But execution completes without any error.

I am really lost right now cause I can't figure how to workaround this.. I really need to have all those actions performed on user intput.

Help would be greatly appreciated,
Adam

lee
Champ in-the-making
Champ in-the-making
Hi Adam,

Did you ever find a solution to this?

I'm getting the same thing happening when behaviours fire on a node - though in my case it's custom behaviours that cause the problem (I can't see from the log attached whether the cause is a custom behaviour or a standard alfresco behaviour).

I'm assuming that the behaviour code needs to test whether a node is locked before attempting any changes to it (in your case createVersion).

But not really certain as that seems a bit arduous to add to all my behaviours.